You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/01/28 02:35:07 UTC

[GitHub] sijie commented on a change in pull request #1055: [Merge Yahoo repo] YBK-154: Add sleep after finding free port given OS time to release it

sijie commented on a change in pull request #1055: [Merge Yahoo repo]  YBK-154: Add sleep after finding free port given OS time to release it
URL: https://github.com/apache/bookkeeper/pull/1055#discussion_r164287173
 
 

 ##########
 File path: bookkeeper-server/src/test/java/org/apache/bookkeeper/test/PortManager.java
 ##########
 @@ -32,19 +30,18 @@
     private static int nextPort = getBasePort();
 
     public static synchronized int nextFreePort() {
+        int exceptionCount = 0;
         while (true) {
-            ServerSocket ss = null;
-            try {
-                int port = nextPort++;
-                ss = new ServerSocket(port);
-                ss.setReuseAddress(true);
+            int port = nextPort++;
+            try (ServerSocket ss = new ServerSocket(port)) {
 
 Review comment:
   @eolivelli
   
   1) this change doesn't change the logic here.
   2) this class is a general test class. so whether a service can use port 0, not depends on this class, but depends on the service logic. some service (e.g. bookie) at some test cases can use port 0, some can't. whether a service can or not is a question of the service not the util.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services