You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Justin Bertram (Jira)" <ji...@apache.org> on 2020/01/13 15:02:00 UTC

[jira] [Commented] (ARTEMIS-2594) TypedProperties#getLongProperty throws java.lang.NumberFormatException if property is not set / null

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

Justin Bertram commented on ARTEMIS-2594:
-----------------------------------------

I believe you're observing the intended behavior. The comment at the top of {{org.apache.activemq.artemis.utils.collections.TypedProperties}} states:

bq. This implementation follows section 3.5.4 of the Java Message Service specification (Version 1.1 April 12, 2002).

Section 3.5.4 of the JMS 1.1 spec says (among other things):

bq. Attempting to read a {{null}} value as a Java primitive type must be treated as calling the primitive’s corresponding {{valueOf(String)}} conversion method with a {{null}} value.

FWIW, the JMS 2.0 spec has the same statement.

> TypedProperties#getLongProperty throws java.lang.NumberFormatException if property is not set / null
> ----------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-2594
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2594
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.10.1
>         Environment: CentOS 5.4.10 x86_64 GNU/Linux, openjdk version "11.0.3" 2019-04-16 LTS
>            Reporter: Andre Flakowski
>            Priority: Major
>
> See:
> {code:java}
> org.apache.activemq.artemis.utils.collections.TypedProperties#getLongProperty{code}
> [https://github.com/apache/activemq-artemis/blob/2.10.1/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/TypedProperties.java#L234]
> if the value for the key is not present / null, 
> {code:java}
> Long.valueOf(null);{code}
> is invoked which will always throw a java.lang.NumberFormatException
> presumably null should be returned and  the behaviour would be:
> {code:java}
> Long number = request.getLongProperty(key);
> if (number != null) {
>     Long sum = Long.sum(42, number);
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)