You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Ekaterina Zilotina (Jira)" <ji...@apache.org> on 2024/08/02 08:34:00 UTC

[jira] [Commented] (ARTEMIS-4805) Null dereferencing in ScaleDownHandler.java

    [ https://issues.apache.org/jira/browse/ARTEMIS-4805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17870409#comment-17870409 ] 

Ekaterina Zilotina commented on ARTEMIS-4805:
---------------------------------------------

+1
How about to optimize [this null return|https://github.com/apache/activemq-artemis/blob/47acdc451703f4e6ace1dd380e7a298b3aa73d57/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java#L849]? 
For example, it can return not null value (maybe just empty {*}session{*}), or throw ActiveMQException in this case at all. In theory, this would eliminate the need to check for null everywhere a *session* is created. 

> Null dereferencing in ScaleDownHandler.java
> -------------------------------------------
>
>                 Key: ARTEMIS-4805
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4805
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Galkin Alexey
>            Priority: Major
>
> In [line 333|https://github.com/apache/activemq-artemis/blob/main/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java] in file {{ScaleDownHandler.java}} variable {{queueCreateSession}} is initialized
> {code:java}
> ClientSession queueCreateSession = sessionFactory.createSession(user, password, false, true, true, false, 0);{code}
> In  [line 851|https://github.com/apache/activemq-artemis/blob/main/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java] in {{ClientSessionFactoryImp.java}}, the code synchronizes with the {{sessions}} collection and checks whether the current session is closed or whether the client protocol manager is down. If the closed session or inactive client protocol manager condition is met, the session is closed and {{null}} is returned
> {code:java}
> if (closed || !clientProtocolManager.isAlive()) {
>    session.close();
>    return null;
> }{code}
> The {{queueCreateSession}} variable could potentially be {{null}}.
> In [line 357|https://github.com/apache/activemq-artemis/blob/main/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java] in file {{ScaleDownHandler.java}} variable {{queueCreateSession}} is passed to the function {{createQueueWithRoutingTypeIfNecessaryAndGetID}} as the first argument:
> {code:java}
> queueID = createQueueWithRoutingTypeIfNecessaryAndGetID(queueCreateSession, queue, message.getAddressSimpleString(), message.getRoutingType());{code}
> In [line 450|https://github.com/apache/activemq-artemis/blob/main/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java] in file {{ScaleDownHandler.java}} potential {{null}} dereference occurs:
> {code:java}
> session.createQueue(new QueueConfiguration(...));{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@activemq.apache.org
For additional commands, e-mail: issues-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact