ASF Bugzilla – Attachment 27202 Details for
Bug 51400
Use of "new String(byte[] b, String enc)" hits Sun JVM bottleneck
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to prepopulate available charsets
patch.txt (text/plain), 2.47 KB, created by
Konstantin Preißer
on 2011-06-23 20:24:24 UTC
(
hide
)
Description:
Patch to prepopulate available charsets
Filename:
MIME Type:
Creator:
Konstantin Preißer
Created:
2011-06-23 20:24:24 UTC
Size:
2.47 KB
patch
obsolete
>Index: java/org/apache/tomcat/util/buf/B2CConverter.java >=================================================================== >--- java/org/apache/tomcat/util/buf/B2CConverter.java (revision 1138858) >+++ java/org/apache/tomcat/util/buf/B2CConverter.java (working copy) >@@ -23,9 +23,9 @@ > import java.io.InputStreamReader; > import java.io.UnsupportedEncodingException; > import java.nio.charset.Charset; >-import java.nio.charset.IllegalCharsetNameException; >-import java.nio.charset.UnsupportedCharsetException; >-import java.util.concurrent.ConcurrentHashMap; >+import java.util.HashMap; >+import java.util.Map.Entry; >+import java.util.SortedMap; > > /** Efficient conversion of bytes to character . > * >@@ -44,28 +44,26 @@ > private static final org.apache.juli.logging.Log log= > org.apache.juli.logging.LogFactory.getLog( B2CConverter.class ); > >- private static final ConcurrentHashMap<String, Charset> encodingToCharsetCache = >- new ConcurrentHashMap<String, Charset>(); >+ private static final HashMap<String, Charset> encodingToCharsetCache = >+ new HashMap<String, Charset>(); >+ >+ static { >+ SortedMap<String, Charset> charsets = Charset.availableCharsets(); >+ for (Entry<String, Charset> e : charsets.entrySet()) { >+ Charset cs = e.getValue(); >+ encodingToCharsetCache.put(e.getKey().toLowerCase(), cs); >+ for (String alias : cs.aliases()) { >+ encodingToCharsetCache.put(alias.toLowerCase(), cs); >+ } >+ } >+ } > > public static Charset getCharset(String enc) > throws UnsupportedEncodingException{ >- >- Charset charset = encodingToCharsetCache.get(enc); >+ >+ Charset charset = encodingToCharsetCache.get(enc.toLowerCase()); > if (charset == null) { >- try { >- charset = Charset.forName(enc); >- } catch (IllegalCharsetNameException icne) { >- UnsupportedEncodingException uee = >- new UnsupportedEncodingException(); >- uee.initCause(icne); >- throw uee; >- } catch (UnsupportedCharsetException uce) { >- UnsupportedEncodingException uee = >- new UnsupportedEncodingException(); >- uee.initCause(uce); >- throw uee; >- } >- encodingToCharsetCache.put(enc, charset); >+ throw new UnsupportedEncodingException(enc); > } > return charset; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51400
:
27186
|
27189
|
27202
|
27211
|
27212
|
27213
|
27214
|
27219