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();
|
connection.start();
|
||||||
} catch (JMSException e) {
|
} catch (JMSException e) {
|
||||||
started.set(false);
|
started.set(false);
|
||||||
|
if (isReconnectOnException()) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,17 @@ public class PooledConnectionSecurityExceptionTest {
|
||||||
LOG.info("Successfully create new connection.");
|
LOG.info("Successfully create new connection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailureGetsNewConnectionOnRetryLooped() throws Exception {
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
testFailureGetsNewConnectionOnRetry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailureGetsNewConnectionOnRetry() throws Exception {
|
public void testFailureGetsNewConnectionOnRetry() throws Exception {
|
||||||
|
pooledConnFact.setMaxConnections(1);
|
||||||
|
|
||||||
final PooledConnection connection1 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
|
final PooledConnection connection1 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -122,19 +131,19 @@ public class PooledConnectionSecurityExceptionTest {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSatisified() throws Exception {
|
public boolean isSatisified() throws Exception {
|
||||||
return connection1.getConnection() !=
|
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 {
|
try {
|
||||||
connection2.start();
|
connection2.start();
|
||||||
fail("Should fail to connect");
|
fail("Should fail to connect");
|
||||||
} catch (JMSSecurityException ex) {
|
} catch (JMSSecurityException ex) {
|
||||||
LOG.info("Caught expected security error");
|
LOG.info("Caught expected security error");
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotSame(connection1.getConnection(), connection2.getConnection());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue