diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java index 84e24953c39..ed7f750c5b0 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java @@ -240,4 +240,7 @@ public interface ActiveMQClientMessageBundle { @Message(id = 219068, value = "Connection closed while receiving cluster topology. Group:{}") ActiveMQObjectClosedException connectionClosedOnReceiveTopology(DiscoveryGroup discoveryGroup); + + @Message(id = 219069, value = "Unable to create Session. Either the ClientSessionFactory is closed or the ClientProtocolManager is dead.") + IllegalStateException unableToCreateSession(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java index 85fe03593a1..c609dd0d880 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java @@ -846,7 +846,7 @@ private ClientSession createSessionInternal(final String rawUsername, synchronized (sessions) { if (closed || !clientProtocolManager.isAlive()) { session.close(); - return null; + throw ActiveMQClientMessageBundle.BUNDLE.unableToCreateSession(); } sessions.add(session); }