Skip to content

Commit

Permalink
ARTEMIS-1935: Close of openwire connection should closes all open ses…
Browse files Browse the repository at this point in the history
…sions

This is my ammending to the last commit
I'm adding some extra verifications to the test
and I fixed a leak that already existed on the previous map

(cherry picked from commit b360fa6)
  • Loading branch information
clebertsuconic committed Jun 15, 2018
1 parent f41e551 commit 838cca4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Expand Up @@ -1013,6 +1013,7 @@ public AMQSession addSession(SessionInfo ss, boolean internal) {
public void removeSession(AMQConnectionContext context, SessionInfo info) throws Exception {
AMQSession session = sessions.remove(info.getSessionId());
if (session != null) {
sessionIdMap.remove(session.getCoreSession().getName());
session.close();
}
}
Expand Down
Expand Up @@ -61,12 +61,22 @@ public void testInternalSessionHandling() throws Exception {
public void testInternalSessionHandlingNoSessionClose() throws Exception {
try (Connection conn = factory.createConnection()) {
conn.start();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = createDestination(session,ActiveMQDestination.QUEUE_TYPE);
sendMessages(session, dest, 1);
MessageConsumer consumer = session.createConsumer(dest);
Message m = consumer.receive(2000);
assertNotNull(m);
for (int i = 0; i < 100; i++) {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = createDestination(session,ActiveMQDestination.QUEUE_TYPE);
sendMessages(session, dest, 1);
MessageConsumer consumer = session.createConsumer(dest);
Message m = consumer.receive(2000);
consumer.close();
assertNotNull(m);

if (i % 2 == 1) {
// it will close only half of the sessions
// just to introduce error conditions
session.close();
}

}
}
assertFalse(AssertionLoggerHandler.findText("Client connection failed, clearing up resources for session"));
assertFalse(AssertionLoggerHandler.findText("Cleared up resources for session"));
Expand Down

0 comments on commit 838cca4

Please sign in to comment.