river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r633092 - /incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java
Date Mon, 03 Mar 2008 14:22:43 GMT
Author: vinod
Date: Mon Mar  3 06:22:42 2008
New Revision: 633092

URL: http://svn.apache.org/viewvc?rev=633092&view=rev
Log:
Fix for RIVER-245

Modified:
    incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java

Modified: incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java?rev=633092&r1=633091&r2=633092&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java (original)
+++ incubator/river/jtsk/trunk/src/com/sun/jini/discovery/internal/MultiIPDiscovery.java Mon
Mar  3 06:22:42 2008
@@ -130,33 +130,37 @@
 	throws IOException, ClassNotFoundException
     {
 	Socket s = new Socket();
-	if (connectionTimeout > Integer.MAX_VALUE) {
-	    s.connect(new InetSocketAddress(host, port));
-	} else {
-	    s.connect(new InetSocketAddress(host, port), 
-		      (int) connectionTimeout);
-	}
-	try {
-	    s.setTcpNoDelay(true);
-	} catch (SocketException e) {
-	    // ignore possible failures and proceed anyway
-	}
-	try {
-	    s.setKeepAlive(true);
-	} catch (SocketException e) {
-	    // ignore possible failures and proceed anyway
-	}
-	s.setSoTimeout(dc.getUnicastSocketTimeout(
-			getDefaultUnicastSocketTimeout()));
-	try {
-	    return performDiscovery(disco, dc, s);
-	} finally {
-	    try {
-		s.close();
-	    } catch (IOException e) {
-		socketCloseException(e);
-	    }
-	}
+        boolean discoveryAttempted = false;
+        try {
+            if (connectionTimeout > Integer.MAX_VALUE) {
+                s.connect(new InetSocketAddress(host, port));
+            } else {
+                s.connect(new InetSocketAddress(host, port), 
+                          (int) connectionTimeout);
+            }
+            try {
+                s.setTcpNoDelay(true);
+            } catch (SocketException e) {
+                // ignore possible failures and proceed anyway
+            }
+            try {
+                s.setKeepAlive(true);
+            } catch (SocketException e) {
+                // ignore possible failures and proceed anyway
+            }
+            s.setSoTimeout(dc.getUnicastSocketTimeout(
+                            getDefaultUnicastSocketTimeout()));
+            discoveryAttempted = true;
+            return performDiscovery(disco, dc, s);
+        } finally {
+            try {
+                s.close();
+            } catch (IOException e) {
+                if (discoveryAttempted) {
+                    socketCloseException(e);
+                }
+            }
+        }
     }
     
     /*
@@ -181,7 +185,7 @@
     }
     
     /*
-     * Called when close of a socket on which discovery has been performed
+     * Called when close of a socket on which discovery has been attempted
      * fails. This class implements this method to do nothing by default.
      */
     protected void socketCloseException(IOException ex) {}
@@ -195,4 +199,4 @@
 							Socket s)
 	throws IOException, ClassNotFoundException;
 	    
-}
\ No newline at end of file
+}



Mime
View raw message