Roland Weber wrote:
Hi Oleg,
works for blackdown 1.4.2 and IBM 1.5.0. Fails with IBM 1.4.2 because
of a bug in the EncodingUtils class:
[java] 1)
testInvalidEncoding(org.apache.http.util.TestEncodingUtils)java.nio.charset.IllegalCharsetNameException:
This just aint right
[java] at java.nio.charset.Charset.checkName(Charset.java:305)
[java] at java.nio.charset.Charset.lookup(Charset.java:439)
[java] at java.nio.charset.Charset.forName(Charset.java:477)
[java] at
java.lang.StringCoding$DecoderCache.makeDecoder(StringCoding.java:109)
[java] at java.lang.StringCoding$1.run(StringCoding.java:155)
[java] at java.security.AccessController.doPrivileged1(Native Method)
[java] at
java.security.AccessController.doPrivileged(AccessController.java:351)
[java] at
java.lang.StringCoding$DecoderCache.getDecoder(StringCoding.java:152)
[java] at java.lang.StringCoding.getDecoder(StringCoding.java:304)
[java] at java.lang.StringCoding.decode(StringCoding.java:383)
[java] at java.lang.String.<init>(String.java:740)
[java] at
org.apache.http.util.EncodingUtils.getString(EncodingUtils.java:74)
[java] at
org.apache.http.util.EncodingUtils.getString(EncodingUtils.java:96)
[java] at
org.apache.http.util.TestEncodingUtils.testInvalidEncoding(TestEncodingUtils.java:190)
The JavaDoc for class Charset lists the valid characters in a charset name:
http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html
The space character used in the test is not among them. blackdown 1.4.2
and IBM 1.5.0 throw an UnsupportedEncodingException which is handled by
the catch in EncodingUtils. IBM 1.4.2 throws an IllegalCharsetNameException,
which is a correct reaction but not handled in EncodingUtils.
I suggest to change all catch(UnsupportedEncodingException) to
catch(RuntimeException), to avoid adding two catch clauses with
duplicate error handling code.
Hi Roland,
I think it would be prudent on our part to differentiate unsupported
charsets from illegal ones and treat them differently. So, I just
tweaked the test case to use a legal charset name, instead of making
EncodingUtils catch all runtime exceptions.
Generally I think this is a very bad practice to catch runtime
exceptions indiscriminately, because you may well end up catching NPE
and OutOfMemory exceptions as well, which to me should clearly be fatal
and should result in the termination of the process (thread)
Oleg
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]