Skip to content

Commit 84b41e7

Browse files
committed
Make sure to keep trying if the first attempt to get a new connection fails
1 parent 822fe30 commit 84b41e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionSecurityExceptionTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ public void testFailureGetsNewConnectionOnRetry() throws Exception {
134134
@Override
135135
public boolean isSatisified() throws Exception {
136136
try (final PooledConnection newConnection = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials")) {
137-
return connection1.getConnection() != newConnection.getConnection();
137+
return connection1.pool != ((PooledConnection)newConnection).pool;
138+
} catch (Exception e) {
139+
return false;
138140
}
139141
}
140142
}));
141143

142144
final PooledConnection connection2 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
143-
assertNotSame(connection1.getConnection(), connection2.getConnection());
145+
assertNotSame(connection1.pool, connection2.pool);
144146

145147
try {
146148
connection2.start();
@@ -233,13 +235,15 @@ public void testFailoverWithInvalidCredentials() throws Exception {
233235
@Override
234236
public boolean isSatisified() throws Exception {
235237
try (final PooledConnection newConnection = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials")) {
236-
return connection1.getConnection() != newConnection.getConnection();
238+
return connection1.pool != ((PooledConnection)newConnection).pool;
239+
} catch (Exception e) {
240+
return false;
237241
}
238242
}
239243
}));
240244

241245
final PooledConnection connection2 = (PooledConnection) pooledConnFact.createConnection("invalid", "credentials");
242-
assertNotSame(connection1.getConnection(), connection2.getConnection());
246+
assertNotSame(connection1.pool, connection2.pool);
243247

244248
try {
245249
connection2.start();
@@ -410,4 +414,4 @@ protected BrokerPlugin configureAuthorization() throws Exception {
410414

411415
return authorizationPlugin;
412416
}
413-
}
417+
}

0 commit comments

Comments
 (0)