You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2012/11/27 17:19:59 UTC

[jira] [Commented] (LANG-707) Add methods to avoid Sun JVM synchronisation overhead in new String(byte[] b, String enc)

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

Gary Gregory commented on LANG-707:
-----------------------------------

This seems to me like the (1) wrong way to fix the problem, in addition to it being incorrect (2).

If you have a problem with String(byte[], String) then why not use String(byte[], Charset)?

The patch pre-loads a huge Map in a static but this map will be out of date as soon as the static initializer completes because Charset.availableCharsets() is dynamic in nature: it will return more Charsets when more are added, from the Javadoc:

{code:java}
     * <p> This method may return different results at different times if new
     * charset providers are dynamically made available to the current Java
     * virtual machine.  In the absence of such changes, the charsets returned
     * by this method are exactly those that can be retrieved via the {@link
     * #forName forName} method.  </p>
{code}

In addition:

{code:java}
     * <p> The invocation of this method, and the subsequent use of the
     * resulting map, may cause time-consuming disk or network I/O operations
     * to occur.  This method is provided for applications that need to
     * enumerate all of the available charsets, for example to allow user
     * charset selection.  This method is not used by the {@link #forName
     * forName} method, which instead employs an efficient incremental lookup
     * algorithm.
{code}

All of this tells me that we should not do anything in this area in this component, at least not as currently proposed.

Also coding in something that might be irrelevant on other JREs is not so nice.
Gary

                
> Add methods to avoid Sun JVM synchronisation overhead in new String(byte[] b, String enc)
> -----------------------------------------------------------------------------------------
>
>                 Key: LANG-707
>                 URL: https://issues.apache.org/jira/browse/LANG-707
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: General
>         Environment: https://issues.apache.org/bugzilla/show_bug.cgi?id=51400
>            Reporter: Sebb
>             Fix For: 3.x
>
>         Attachments: LANG-707.diff
>
>
> According to Tomcat bug 51400, the use of new String(byte[] b, String enc) can fall foul of a Sun Java synchronisation bottleneck.
> Might be useful to add the code workround to Commons Lang.

--
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