You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/27 17:19:22 UTC
svn commit: r1140204 -
/tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
Author: markt
Date: Mon Jun 27 15:19:22 2011
New Revision: 1140204
URL: http://svn.apache.org/viewvc?rev=1140204&view=rev
Log:
Need to include aliases in charset cache
Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java?rev=1140204&r1=1140203&r2=1140204&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java Mon Jun 27 15:19:22 2011
@@ -55,8 +55,11 @@ public class B2CConverter {
static {
for (Entry<String,Charset> entry :
Charset.availableCharsets().entrySet()) {
- encodingToCharsetCache.put(entry.getKey().toLowerCase(),
- entry.getValue());
+ Charset charset = entry.getValue();
+ encodingToCharsetCache.put(entry.getKey().toLowerCase(), charset);
+ for (String alias : charset.aliases()) {
+ encodingToCharsetCache.put(alias, charset);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1140204 - /tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
Posted by Tim Funk <fu...@apache.org>.
The javadocs say it can be an "expensive" operation. But considering the
alternatives [and this is only done once], this seems to be reasonable.
What could be worrisome is the JDK does allow for more charsets to be added
at run-time. In which case - a user could be out of luck.
If we were scared of performance at startup .. we could always have a
System.properties of comma separated entries as the source of charset names
instead of worrying about Charset.availableCharsets(). In which case
"iso8859-1,utf-8" might be enough for some users.
-Tim
On Mon, Jun 27, 2011 at 11:49 AM, Konstantin Kolinko <knst.kolinko@gmail.com
> wrote:
> 2011/6/27 <ma...@apache.org>:
> > Author: markt
> > Date: Mon Jun 27 15:19:22 2011
> > New Revision: 1140204
> >
> > URL: http://svn.apache.org/viewvc?rev=1140204&view=rev
> > Log:
> > Need to include aliases in charset cache
> >
> > Modified:
> > tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
> >
> I was wondering how slow is Charset.availableCharsets().
> In my test it is about 100ms. Nothing to worry about.
>
>
Re: svn commit: r1140204 - /tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/6/27 <ma...@apache.org>:
> Author: markt
> Date: Mon Jun 27 15:19:22 2011
> New Revision: 1140204
>
> URL: http://svn.apache.org/viewvc?rev=1140204&view=rev
> Log:
> Need to include aliases in charset cache
>
> Modified:
> tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
>
15:19:22 2011
> @@ -55,8 +55,11 @@ public class B2CConverter {
> static {
> for (Entry<String,Charset> entry :
> Charset.availableCharsets().entrySet()) {
> - encodingToCharsetCache.put(entry.getKey().toLowerCase(),
> - entry.getValue());
> + Charset charset = entry.getValue();
> + encodingToCharsetCache.put(entry.getKey().toLowerCase(), charset);
Getting the name can be a bit simplified:
charset.name().toLowerCase(Locale.US)
thus no need to access the key and loop can be simplified a bit.
> + for (String alias : charset.aliases()) {
> + encodingToCharsetCache.put(alias, charset);
Should be:
s/alias/alias.toLowerCase(Locale.US)/
> + }
> }
> }
I was wondering how slow is Charset.availableCharsets().
In my test it is about 100ms. Nothing to worry about.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org