commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1533434 - /commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
Date Fri, 18 Oct 2013 13:01:30 GMT
Author: tv
Date: Fri Oct 18 13:01:29 2013
New Revision: 1533434

URL: http://svn.apache.org/r1533434
Log:
Make sure that socket is closed

Modified:
    commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java

Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java?rev=1533434&r1=1533433&r2=1533434&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
Fri Oct 18 13:01:29 2013
@@ -488,11 +488,13 @@ public class LateralTCPListener<K extend
         @Override
         public void run()
         {
+        	ServerSocket serverSocket = null;
+        	
             try
             {
                 log.info( "Listening on port " + port );
 
-                ServerSocket serverSocket = new ServerSocket( port );
+                serverSocket = new ServerSocket( port );
                 serverSocket.setSoTimeout( acceptTimeOut );
 
                 ConnectionHandler handler;
@@ -541,10 +543,24 @@ public class LateralTCPListener<K extend
                     pooledExecutor.execute( handler );
                 }
             }
-            catch ( Exception e )
+            catch ( IOException e )
             {
                 log.error( "Exception caught in TCP listener", e );
             }
+            finally
+            {
+            	if (serverSocket != null)
+            	{
+            		try 
+            		{
+						serverSocket.close();
+					}
+            		catch (IOException e) 
+            		{
+                        log.error( "Exception caught closing socket", e );
+					}
+            	}
+            }
         }
     }
 
@@ -569,7 +585,7 @@ public class LateralTCPListener<K extend
         /**
          * Main processing method for the LateralTCPReceiverConnection object
          */
-        @SuppressWarnings("unchecked") // Nee to cast from Object
+        @SuppressWarnings("unchecked") // Need to cast from Object
         public void run()
         {
             ObjectInputStream ois;



Mime
View raw message