gemmellr commented on code in PR #4482:
URL: https://github.com/apache/activemq-artemis/pull/4482#discussion_r1197664105
##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ServerLocatorConnectTest.java:
##########
@@ -47,6 +52,47 @@ public void setUp() throws Exception {
server.start();
}
+ @Test
+ public void testFailFastConnectOnClosing() throws Exception {
+ CountDownLatch connectLatch = new CountDownLatch(1);
+ CountDownLatch subscribeLatch = new CountDownLatch(1);
+ AtomicBoolean connectTimedOut = new AtomicBoolean(false);
+
+ ServerLocator locator =
createNonHALocator(isNetty()).setCallTimeout(30000);
+ try (ClientSessionFactory csf = locator.createSessionFactory()) {
+ Assert.assertFalse(csf.isClosed());
+ }
+
+ server.getRemotingService().addIncomingInterceptor((Interceptor)
(packet, connection) -> {
+ if (packet.getType() == PacketImpl.SUBSCRIBE_TOPOLOGY_V2) {
+ subscribeLatch.countDown();
+ return false;
+ }
+ return true;
+ });
+
+ new Thread(() -> {
+ try {
+ locator.createSessionFactory();
+ } catch (Exception e) {
+ connectTimedOut.set(e.getClass() ==
ActiveMQConnectionTimedOutException.class);
Review Comment:
Throwing an explicit timeout exception for a fast-fail due to closure, feels
a little off...seeing e.g a stack/log, people might think that the configured
timeout was hit, when in this case it now wouldnt be as the test specifically
verifies.
I guess it actually throws a TimeoutException previously/currently, after
the e.g. 30 seconds configured, so the type wouldnt actually be a change here,
but when it is thrown will be changing. It actually timed out before, while
with this it wouldnt..so perhaps instead an exception to more clearly signal
the failure was always the result of it being closed?
--
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]