Author: fhanik
Date: Wed Nov 19 14:26:06 2008
New Revision: 719096
URL: http://svn.apache.org/viewvc?rev=719096&view=rev
Log:
fix NPE risk
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=719096&r1=719095&r2=719096&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Wed Nov 19
14:26:06 2008
@@ -1429,7 +1429,8 @@
processSocket(ka.getChannel(), status, false); //don't
dispatch if the lines below are cancelling the key
}
}
- handler.release(ka.getChannel());
+
+ if (ka!=null) handler.release(ka.getChannel());
if (key.isValid()) key.cancel();
if (key.channel().isOpen()) try {key.channel().close();}catch
(Exception ignore){}
try {ka.channel.close(true);}catch (Exception ignore){}
@@ -1610,13 +1611,26 @@
sd.length -= written;
}
if ( sd.length <= 0 ) {
+ if (log.isDebugEnabled()) {
+ log.debug("Send file complete for:"+sd.fileName);
+ }
attachment.setSendfileData(null);
if ( sd.keepAlive ) {
+ if (log.isDebugEnabled()) {
+ log.debug("Connection is keep alive, registering
back for OP_READ");
+ }
if (reg) reg(sk,attachment,SelectionKey.OP_READ);
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("Send file connection is being closed");
+ }
cancelledKey(sk,SocketStatus.STOP,false);
}
} else if ( attachment.interestOps() == 0 && reg ) {
+ if (log.isDebugEnabled()) {
+ log.debug("OP_WRITE for sendilfe:"+sd.fileName);
+ }
+
reg(sk,attachment,SelectionKey.OP_WRITE);
}
}catch ( IOException x ) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]