Skip to content

Commit 6982c90

Browse files
committed
Add retry logic and additional wait time for FTPS server startup
The FTPS tests were experiencing timeout errors on CI when trying to connect to the embedded FTP server. The issue was that the server was being started but not fully ready to accept connections before the tests tried to connect. Changes: - Added retry loop (up to 2 seconds) to wait for server to not be stopped/suspended - Added additional 200ms wait after server reports ready to ensure it's fully accepting connections - This prevents "Read timed out" errors when tests try to connect immediately after server startup The original code only waited 200ms if the server was stopped/suspended, but didn't wait for the server to be fully ready. The new code: 1. Waits up to 2 seconds for server to start (checking every 100ms) 2. Then waits an additional 200ms for server to be fully ready This should resolve the intermittent timeout failures on CI while maintaining fast test execution when the server starts quickly. Test results: - Tests run: 2,556 - Failures: 0 ✅ - Errors: 0 ✅ - Skipped: 612
1 parent 7854d69 commit 6982c90

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftps/AbstractFtpsProviderTestCase.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,24 @@ synchronized static void setUpClass(final boolean implicit) throws FtpException
125125
embeddedFtpServer = serverFactory.createServer();
126126
embeddedFtpServer.start();
127127
Thread.yield();
128-
if (embeddedFtpServer.isStopped() || embeddedFtpServer.isSuspended()) {
128+
129+
// Wait for server to be ready
130+
int retries = 20; // Wait up to 2 seconds
131+
while (retries-- > 0 && (embeddedFtpServer.isStopped() || embeddedFtpServer.isSuspended())) {
129132
try {
130-
Thread.sleep(200);
133+
Thread.sleep(100);
131134
} catch (final InterruptedException e) {
132135
e.printStackTrace();
133136
}
134137
}
138+
139+
// Additional wait to ensure the server is fully ready to accept connections
140+
try {
141+
Thread.sleep(200);
142+
} catch (final InterruptedException e) {
143+
e.printStackTrace();
144+
}
145+
135146
socketPort = ((org.apache.ftpserver.impl.DefaultFtpServer) embeddedFtpServer).getListener(LISTENER_NAME).getPort();
136147
// System.out.println("Using port " + SocketPort);
137148
// System.out.printf("jdk.tls.disabledAlgorithms = %s%n", System.getProperty("jdk.tls.disabledAlgorithms"));

0 commit comments

Comments
 (0)