Author: markt Date: Tue Mar 24 13:04:37 2015 New Revision: 1668873 URL: http://svn.apache.org/r1668873 Log: Avoid NPE reported in https://bz.apache.org/bugzilla/show_bug.cgi?id=57749 and log the exception.
Modified: tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/LocalStrings.properties Modified: tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java?rev=1668873&r1=1668872&r2=1668873&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java Tue Mar 24 13:04:37 2015 @@ -32,6 +32,8 @@ import javax.servlet.RequestDispatcher; import org.apache.coyote.OutputBuffer; import org.apache.coyote.Response; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.net.AbstractEndpoint; import org.apache.tomcat.util.net.Nio2Channel; @@ -44,6 +46,8 @@ import org.apache.tomcat.util.net.Socket */ public class InternalNio2OutputBuffer extends AbstractOutputBuffer<Nio2Channel> { + private static final Log log = LogFactory.getLog(InternalNio2OutputBuffer.class); + // ----------------------------------------------------------- Constructors /** @@ -151,6 +155,11 @@ public class InternalNio2OutputBuffer ex @Override public void failed(Throwable exc, ByteBuffer attachment) { + if (socket == null) { + log.warn(sm.getString("iob.nio2.nullSocket"), exc); + // Can't do anything else with a null socket + return; + } socket.setError(true); if (exc instanceof IOException) { e = (IOException) exc; @@ -202,6 +211,11 @@ public class InternalNio2OutputBuffer ex @Override public void failed(Throwable exc, ByteBuffer[] attachment) { + if (socket == null) { + log.warn(sm.getString("iob.nio2.nullSocket"), exc); + // Can't do anything else with a null socket + return; + } socket.setError(true); if (exc instanceof IOException) { e = (IOException) exc; Modified: tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/LocalStrings.properties?rev=1668873&r1=1668872&r2=1668873&view=diff ============================================================================== --- tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/LocalStrings.properties (original) +++ tomcat/tc8.0.x/trunk/java/org/apache/coyote/http11/LocalStrings.properties Tue Mar 24 13:04:37 2015 @@ -42,3 +42,5 @@ iob.failedwrite=Failed write iob.failedwrite.ack=Failed to send HTTP 100 continue response iob.illegalreset=The response may not be reset once it has been committed iob.responseheadertoolarge.error=An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers. + +iob.nio2.nullSocket=Socket was null while trying to process exception. See Bug 57749 \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org