Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of exception is (0)null?

I am using Apache Axis, and I am getting exception of type (0)null. Here is partial stack trace:

....
....
org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    at java.lang.Thread.run(Thread.java:744)
Caused by: (0)null
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.netsuite.webservices.platform_2012_1.NetSuiteBindingStub.upsertList(NetSuiteBindingStub.java:11841)
....
....

Following is what I see in HTTPSender source code.

....
AxisFault fault = new AxisFault("HTTP", "(" + returnCode + ")" + statusMessage, null, null);
....
throw fault;
....
like image 952
hrishikeshp19 Avatar asked Feb 27 '14 23:02

hrishikeshp19


1 Answers

So the exception is of type AxisFault, but it looks like statusMessage is null. Line 444 is:

AxisFault fault = new AxisFault("HTTP", "(" + returnCode + ")" + statusMessage, null, null);

The (0)null part comes from "(" + returnCode + ")" + statusMessage. statusMessage itself is assigned in line 742:

String statusMessage = msgContext.getStrProp(HTTPConstants.MC_HTTP_STATUS_MESSAGE);

returnCode is set to 0 early on in the method. The next few statements should set it to its correct value:

Integer rc = (Integer) msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
if (rc != null) {
    returnCode = rc.intValue();
} else {
    // No return code?? Should have one by now.
}

After this, the if block and none of the else if blocks get executed since the return code is 0 (because rc is null). It finally lands up in the else block where it generates the AxisFault exception.

You will notice that the statusMessage itself is null. The only place I can see it setting this property is on line 641, which is the readHeadersFromSocket method.

The only way the status message and the return code will not be set is if they are already null, or if there is an error earlier on in the method, which causes control to break out of the for loop that starts on line 581. Of particular interest are line 585 and line 598, both of which are if statements that will break out of the loop if their test-condition is true. One of these statements checks to see if the value of inp.read() is -1 (which means that the end of the stream has been reached), the other checks to see if the length of what was read in is 0. These conditions can hold true if there is a network error (i.e., nothing read from the socket) or if nothing was returned from the server (zero-length data). So if any of these conditions are true, control breaks out of the loop. Eventually, readFromSocket will throw the exception since it wasn't able to get a return code. But because the failure happened before it could even set an error message, you get a null error message.

tl; dr; There is probably some sort of network/read error.

like image 123
Vivin Paliath Avatar answered Oct 15 '22 08:10

Vivin Paliath