ARTEMIS-3770 mitigate potential NPE
This was being triggered by org.apache.activemq.artemis.tests.integration.routing.MQTTRedirectTest.
This commit is contained in:
parent
bed9af2e51
commit
3a0658c202
|
@ -448,10 +448,14 @@ public class MQTTProtocolHandler extends ChannelInboundHandlerAdapter {
|
|||
private void disconnectExistingSession(MQTTConnection existingConnection) {
|
||||
if (existingConnection != null) {
|
||||
MQTTSession existingSession = session.getProtocolManager().getSessionState(session.getConnection().getClientID()).getSession();
|
||||
if (existingSession != null) {
|
||||
if (session.getVersion() == MQTTVersion.MQTT_5) {
|
||||
existingSession.getProtocolHandler().sendDisconnect(MQTTReasonCodes.SESSION_TAKEN_OVER);
|
||||
}
|
||||
existingSession.getConnectionManager().disconnect(false);
|
||||
} else {
|
||||
existingConnection.disconnect(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue