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

Clebert Suconic commented on ARTEMIS-2769:
------------------------------------------

I would rather get an exception than silently fail as the default on the case 
of a string.


if you like, I would rather throw NumberFormatException with a better 
explanation and the original cause as the cause, or another ArtemisException 
empedded. I wouldn't return a default value here as it may be dangerous on 
silent failing..

> NumberFormatException  
> -----------------------
>
>                 Key: ARTEMIS-2769
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2769
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: ActiveMQ-Artemis-Native
>    Affects Versions: 2.12.0, 2.13.0
>            Reporter: Todor Neykov
>            Assignee: Clebert Suconic
>            Priority: Minor
>              Labels: easyfix
>
> Hi, 
> I found an issue in ConfigurationHelper.getIntProperty() 
> If there is a String propery but not a numeric value it lead to 
> NumberFormatException. 
> My expectation in this case is to be returned a default value instead of 
> exception. 
> The code is
> {code:java}
> if (prop instanceof String) {
>     return Integer.valueOf((String) prop);
> } else ...
>  
> {code}
> Fix proposal : 
> {code:java}
> if (prop instanceof String)
> {
>     try
>     {
>         return Integer.valueOf((String)prop);
>     }
>     catch (NumberFormatException e)
>     {
>         ActiveMQClientLogger.LOGGER.propertyNotInteger(propName, 
> prop.getClass().getName());
>         return def;
>     }
> }
> else ...
> {code}
> Same case is in getLongProperty() 
>  



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

Reply via email to