You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2012/11/10 13:14:17 UTC

svn commit: r1407794 - /river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java

Author: peter_firmstone
Date: Sat Nov 10 12:14:16 2012
New Revision: 1407794

URL: http://svn.apache.org/viewvc?rev=1407794&view=rev
Log:
Catch BindException caused by TIME_WAIT, sleep and retry, to avoid test failure on ARM architecture.

Modified:
    river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java

Modified: river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java?rev=1407794&r1=1407793&r2=1407794&view=diff
==============================================================================
--- river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java (original)
+++ river/jtsk/trunk/qa/src/com/sun/jini/test/share/DiscoveryProtocolSimulator.java Sat Nov 10 12:14:16 2012
@@ -81,6 +81,7 @@ import java.net.UnknownHostException;
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.net.BindException;
 
 import java.nio.ByteBuffer;
 import java.nio.BufferUnderflowException;
@@ -573,7 +574,17 @@ public class DiscoveryProtocolSimulator 
 		}
 	    }
 	    if (listen == null) {
-		listen = new ServerSocket(port);
+                try {
+                    listen = new ServerSocket(port);
+                } catch (BindException e){
+                    try {
+                        Thread.sleep(240000); // TIME_WAIT
+                        listen = new ServerSocket(port); // Try again.
+                    } catch (InterruptedException ex){
+                        ex.fillInStackTrace();
+                        throw new IOException("Interrupted while trying to open a ServerSocket", ex);
+                    }
+                }
 	    }
 	    this.port = listen.getLocalPort();
 	}