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) {
|
private void disconnectExistingSession(MQTTConnection existingConnection) {
|
||||||
if (existingConnection != null) {
|
if (existingConnection != null) {
|
||||||
MQTTSession existingSession = session.getProtocolManager().getSessionState(session.getConnection().getClientID()).getSession();
|
MQTTSession existingSession = session.getProtocolManager().getSessionState(session.getConnection().getClientID()).getSession();
|
||||||
if (session.getVersion() == MQTTVersion.MQTT_5) {
|
if (existingSession != null) {
|
||||||
existingSession.getProtocolHandler().sendDisconnect(MQTTReasonCodes.SESSION_TAKEN_OVER);
|
if (session.getVersion() == MQTTVersion.MQTT_5) {
|
||||||
|
existingSession.getProtocolHandler().sendDisconnect(MQTTReasonCodes.SESSION_TAKEN_OVER);
|
||||||
|
}
|
||||||
|
existingSession.getConnectionManager().disconnect(false);
|
||||||
|
} else {
|
||||||
|
existingConnection.disconnect(false);
|
||||||
}
|
}
|
||||||
existingSession.getConnectionManager().disconnect(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue