gnodet commented on code in PR #22983:
URL: https://github.com/apache/camel/pull/22983#discussion_r3194642619


##########
test-infra/camel-test-infra-ftp/src/main/java/org/apache/camel/test/infra/ftp/services/embedded/SftpEmbeddedInfraService.java:
##########
@@ -136,6 +137,21 @@ public void setUpServer() throws Exception {
         sshd.start();
 
         port = ((InetSocketAddress) 
sshd.getBoundAddresses().iterator().next()).getPort();
+
+        waitForServerReady();
+    }
+
+    private void waitForServerReady() {
+        long deadline = System.nanoTime() + 5_000_000_000L; // 5 seconds
+        while (System.nanoTime() < deadline) {
+            try (Socket socket = new Socket()) {
+                socket.connect(new InetSocketAddress("localhost", port), 1000);
+                return;
+            } catch (IOException e) {
+                Thread.onSpinWait();
+            }
+        }
+        LOG.warn("SFTP server may not be ready after timeout on port {}", 
port);

Review Comment:
   Good point, fixed. The method now throws `IOException` if the server is not 
ready within 5 seconds, so tests fail fast with a clear error message instead 
of proceeding to confusing timeout errors.
   
   _Claude Code on behalf of Guillaume Nodet_



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to