hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Nauroth (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-9252) StringUtils.limitDecimalTo2(..) is unnecessarily synchronized
Date Sat, 02 Feb 2013 06:20:13 GMT

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

Chris Nauroth commented on HADOOP-9252:
---------------------------------------

Thanks, Nicholas.  I should have looked for the interface annotations.

One of the test failures that I spotted was {{TestContainersMonitor}} in hadoop-yarn-server-nodemanager.
 The test failed because of 2 changes in behavior in {{StringUtils#humanReadableInt}} with
this patch:

# There is now a space between the number and the units.
# The unit is upper-case instead of lower-case.

For example, before the patch we would get results like "2.0m", and now we get "2.0 M".  I
made the test pass by removing the append of the extra space and wrapping the unit with {{Character#toLowerCase}}.
 The relevant lines in {{long2String}} with these changes are:

{code}
        return (unit.isEmpty()? b: b.append(unit)).toString();
...
        return b.append(Character.toLowerCase(prefix.symbol)).append(unit).toString();
{code}

I did not do a complete test run though, so I don't know yet if my change introduced other
problems.

Would you want to incorporate something like this into the patch, or do you prefer to keep
the new output and update any tests that depend on the old output?

BTW, I ran a quick non-exhaustive grep of other Hadoop projects and found that HBase has calls
to {{humanReadableInt}} and {{limitDecimalTo2}}.  I don't know yet if there are any test impacts
there.

                
> StringUtils.limitDecimalTo2(..) is unnecessarily synchronized
> -------------------------------------------------------------
>
>                 Key: HADOOP-9252
>                 URL: https://issues.apache.org/jira/browse/HADOOP-9252
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: util
>            Reporter: Tsz Wo (Nicholas), SZE
>            Assignee: Tsz Wo (Nicholas), SZE
>            Priority: Minor
>         Attachments: c9252_20130127.patch, c9252_20130128.patch
>
>
> limitDecimalTo2(double) currently uses decimalFormat, which is a static field, so that
it is synchronized.  Synchronization is unnecessary since it can simply uses String.format(..).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message