Dear all,
During performance and stability run, we encountered one tomcat issue, i.e.
sometimes a NullPointerException is thrown when executing
org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket. This issue was
happened very rarely.
Following is the stack:
PRS0: Http response exception : java.lang.NullPointerException
org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:463)
org.apache.coyote.http11.InternalNioOutputBuffer.flushBuffer(InternalNioOutputBuffer.java:800)
org.apache.coyote.http11.InternalNioOutputBuffer.endRequest(InternalNioOutputBuffer.java:412)
org.apache.coyote.http11.Http11NioProcessor.action(Http11NioProcessor.java:1097)
org.apache.coyote.Response.action(Response.java:183)
org.apache.coyote.Response.finish(Response.java:305)
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:284)
org.apache.catalina.connector.CoyoteWriter.close(CoyoteWriter.java:108)
....
The tomcat version is 6.0.35. I checked the source code, the exception occurred
at line 463 of InternalNioOutputBuffer.java, which is marked in red.
private synchronized int writeToSocket(ByteBuffer bytebuffer, boolean block,
boolean flip) throws IOException {
......
......
try {
written = getSelectorPool().write(bytebuffer, socket, selector,
writeTimeout, block,lastWrite);
//make sure we are flushed
do {
if (socket.flush(true,selector,writeTimeout,lastWrite)) break;
}while ( true );
}finally {
if ( selector != null ) getSelectorPool().put(selector);
}
......
......
}
Before executing line 460 (i.e. written = getSelectorPool().write(bytebuffer,
socket, selector, writeTimeout, block,lastWrite)),socket object should not be
null.
So I guess socket is recycled after executing line 460 so that
NullPointException is thrown. But I am not sure why the socket is recycled.
Client closes the TCP connection? TCP write timeout? TCP is reset?
I appreciate your help and thanks for your time in advance.
Thanks
Eric