You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/05/05 05:16:07 UTC

[GitHub] [hbase] virajjasani commented on a change in pull request #1652: HBASE-24325: TestJMXConnectorServer can fail to start the minicluster…

virajjasani commented on a change in pull request #1652:
URL: https://github.com/apache/hbase/pull/1652#discussion_r419867480



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/TestJMXConnectorServer.java
##########
@@ -219,4 +222,18 @@ public void preExecuteProcedures(ObserverContext<RegionServerCoprocessorEnvironm
       // the systemuser nor the superuser so we can not call executeProcedures...
     }
   }
+
+  protected static int getFreePort() throws IOException {
+    ServerSocket s = new ServerSocket(0);
+    try {

Review comment:
       Good to use try-with-resources and simplify this to:
   
   ```
     protected static int getFreePort() throws IOException {
       try (ServerSocket s = new ServerSocket(0)) {
         s.setReuseAddress(true);
         return s.getLocalPort();
       }
     }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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