remm 2002/10/22 02:42:49
Modified: util/java/org/apache/tomcat/util/net PoolTcpEndpoint.java
Log:
- Fix NPE (bug 13842).
- Remove useless logging (maybe the hadshake failure should be an INFO).
- Make sure socket is correctly closed in all cases.
- Tighten up exception handling.
Revision Changes Path
1.6 +26 -9
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java
Index: PoolTcpEndpoint.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PoolTcpEndpoint.java 19 Oct 2002 09:30:37 -0000 1.5
+++ PoolTcpEndpoint.java 22 Oct 2002 09:42:48 -0000 1.6
@@ -510,9 +510,18 @@
try {
if(endpoint.getServerSocketFactory()!=null) {
- endpoint.getServerSocketFactory().handshake(s);
+ endpoint.getServerSocketFactory().handshake(s);
}
-
+ } catch (Throwable t) {
+ endpoint.log("Handshake failed", t, Log.DEBUG);
+ // Try to close the socket
+ try {
+ s.close();
+ } catch (IOException e) {}
+ continue;
+ }
+
+ try {
if( usePool ) {
con=(TcpConnection)connectionCache.get();
if( con == null )
@@ -526,11 +535,19 @@
con.setSocket(s);
endpoint.setSocketOptions( s );
endpoint.getConnectionHandler().processConnection(con, perThrData);
- } catch (IOException e){
- endpoint.log("Handshake failed",e,Log.ERROR);
+ } catch (Throwable t) {
+ endpoint.log("Unexpected error", t, Log.ERROR);
+ // Try to close the socket
+ try {
+ s.close();
+ } catch (IOException e) {}
} finally {
- con.recycle();
- if( usePool && con != null ) connectionCache.put(con);
+ if (con != null) {
+ con.recycle();
+ if (usePool) {
+ connectionCache.put(con);
+ }
+ }
}
break;
}
--
To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>