ARTEMIS-5033 Avoid NPE on method processAddSession in OpenWireConnection

The class org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection in ActiveMQ Artemis
is based on org.apache.activemq.broker.TransportConnection from ActiveMQ Classic,
and in the latter there is null check that doesn't exist in the former.
Therefore, I think it's worth adding this check.

The info should never be null since it is passed in off the wire from the OpenWire marshaller,
and state.getSessionIds() should also never return null because the underlying ConcurrentMap is initialized when ConnectionState is created.
This commit is contained in:
Laurent Dauvilaire 2024-09-04 15:09:38 +02:00 committed by Justin Bertram
parent 1503a40fe7
commit 9702053af2
1 changed files with 1 additions and 1 deletions

View File

@ -1469,7 +1469,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
@Override
public Response processAddSession(SessionInfo info) throws Exception {
// Avoid replaying dup commands
if (!state.getSessionIds().contains(info.getSessionId())) {
if (state != null && !state.getSessionIds().contains(info.getSessionId())) {
addSession(info);
state.addSession(info);
}