mirror of https://github.com/apache/activemq.git
Close failed connection on start if the reconnect on exception flag is enabled.
This commit is contained in:
parent
e53e340262
commit
2e64abc38a
|
@ -125,6 +125,9 @@ public class ConnectionPool implements ExceptionListener {
|
|||
connection.start();
|
||||
} catch (JMSException e) {
|
||||
started.set(false);
|
||||
if (isReconnectOnException()) {
|
||||
close();
|
||||
}
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,8 +105,17 @@ public class PooledConnectionSecurityExceptionTest {
|
|||
LOG.info("Successfully create new connection.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureGetsNewConnectionOnRetryLooped() throws Exception {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
testFailureGetsNewConnectionOnRetry();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureGetsNewConnectionOnRetry() throws Exception {
|
||||
pooledConnFact.setMaxConnections(1);
|
||||
|
||||
final PooledConnection connection1 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
|
||||
|
||||
try {
|
||||
|
@ -122,19 +131,19 @@ public class PooledConnectionSecurityExceptionTest {
|
|||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return connection1.getConnection() !=
|
||||
((PooledConnection) pooledConnFact.createConnection("invalid", "credentials")).getConnection();
|
||||
((PooledConnection) pooledConnFact.createConnection("invalid", "credentials")).getConnection();
|
||||
}
|
||||
}));
|
||||
|
||||
PooledConnection connection2 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
|
||||
final PooledConnection connection2 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
|
||||
assertNotSame(connection1.getConnection(), connection2.getConnection());
|
||||
|
||||
try {
|
||||
connection2.start();
|
||||
fail("Should fail to connect");
|
||||
} catch (JMSSecurityException ex) {
|
||||
LOG.info("Caught expected security error");
|
||||
}
|
||||
|
||||
assertNotSame(connection1.getConnection(), connection2.getConnection());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue