nastra commented on code in PR #13017:
URL: https://github.com/apache/iceberg/pull/13017#discussion_r2086062975


##########
open-api/src/testFixtures/java/org/apache/iceberg/rest/RESTServerExtension.java:
##########
@@ -58,8 +60,23 @@ public RESTCatalog client() {
   public void beforeAll(ExtensionContext extensionContext) throws Exception {
     if (Boolean.parseBoolean(
         
extensionContext.getConfigurationParameter(RCKUtils.RCK_LOCAL).orElse("true"))) 
{
-      this.localServer = new RESTCatalogServer(config);
-      this.localServer.start(false);
+      int maxAttempts = 10;
+      for (int i = 0; i < maxAttempts; i++) {
+        try {
+          if (findFreePort) {
+            config.put(RESTCatalogServer.REST_PORT, 
String.valueOf(RCKUtils.findFreePort()));
+          }
+          this.localServer = new RESTCatalogServer(config);
+          this.localServer.start(false);
+          break;
+        } catch (BindException e) {
+          if (!findFreePort || i == maxAttempts - 1) {
+            throw new RuntimeException("Failed to start REST server", e);
+          }
+        } catch (Exception e) {
+          throw new RuntimeException("Failed to start REST server", e);
+        }
+      }

Review Comment:
   nit: please add a newline after this here



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to