[jboss-jira] [JBoss JIRA] (LOGTOOL-93) Message bundles always use String.format() even if no format is used

David Lloyd (JIRA) issues at jboss.org
Thu Jul 9 21:46:02 EDT 2015


    [ https://issues.jboss.org/browse/LOGTOOL-93?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088353#comment-13088353 ] 

David Lloyd commented on LOGTOOL-93:
------------------------------------

How do you know if formatting is needed?  If a string contains a "%" does that means it needs formatting, or does it mean that a literal % should be emitted?


> Message bundles always use String.format() even if no format is used
> --------------------------------------------------------------------
>
>                 Key: LOGTOOL-93
>                 URL: https://issues.jboss.org/browse/LOGTOOL-93
>             Project: Log Tool
>          Issue Type: Bug
>            Reporter: James Perkins
>            Assignee: James Perkins
>            Priority: Blocker
>             Fix For: 2.1.0.Alpha1
>
>
> The {{String.format()}} should only be used if formatting is needed. 
> {code:java|title=Interface.java}
> @Message("Test message")
> RuntimeException testMessage();
> {code}
> {code:java|title=Interface_$bundle.java}
> @Override
> public final RuntimeException testMessage() {
>     final RuntimeException result = new RuntimeException(String.format(testMessage$str()));
>     final StackTraceElement[] st = result.getStackTrace();
>     result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
>     return result;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the jboss-jira mailing list