ARTEMIS-1935: Close of openwire connection should closes all open sessions

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
This commit is contained in:
Clebert Suconic 2018-06-15 10:32:39 -04:00
parent 39871157b4
commit b360fa6063
2 changed files with 17 additions and 6 deletions

View File

@ -1013,6 +1013,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
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();
}
}

View File

@ -61,12 +61,22 @@ public class SessionHandlingOpenWireTest extends BasicOpenWireTest {
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"));