Fixed issue with registration timeout == 0 (it will now wait indefinitely)

This commit is contained in:
nathan 2019-01-09 19:54:02 +01:00
parent 448223f4c8
commit c609bb7328
3 changed files with 16 additions and 8 deletions

View File

@ -70,12 +70,22 @@ class EndPointClient extends EndPoint {
// have to BLOCK (must be outside of the synchronize call), we don't want the client to run before registration is complete // have to BLOCK (must be outside of the synchronize call), we don't want the client to run before registration is complete
try { try {
if (!registration.await(connectionTimeout, TimeUnit.MILLISECONDS)) { if (connectionTimeout > 0) {
closeConnection(); if (!registration.await(connectionTimeout, TimeUnit.MILLISECONDS)) {
throw new IOException("Unable to complete registration within '" + connectionTimeout + "' milliseconds"); closeConnection();
throw new IOException("Unable to complete registration within '" + connectionTimeout + "' milliseconds");
}
}
else {
registration.await();
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new IOException("Unable to complete registration within '" + connectionTimeout + "' milliseconds", e); if (connectionTimeout > 0) {
throw new IOException("Unable to complete registration within '" + connectionTimeout + "' milliseconds", e);
}
else {
throw new IOException("Unable to complete registration.", e);
}
} }
} }

View File

@ -334,8 +334,7 @@ class RmiGlobalTest extends BaseTest {
} }
}); });
// client.connect(5000); client.connect(5000);
client.connect(0);
waitForThreads(); waitForThreads();
} }

View File

@ -122,8 +122,7 @@ class TestClient
} }
}); });
client.connect(0); client.connect(3000);
client.waitForShutdown(); client.waitForShutdown();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();