IllegalCharsetNameException thrown by 
XmlRpcCommonsTransport.resetClientForRedirect()
-------------------------------------------------------------------------------------

                 Key: XMLRPC-144
                 URL: https://issues.apache.org/jira/browse/XMLRPC-144
             Project: XML-RPC
          Issue Type: Bug
          Components: Source
    Affects Versions: 3.1
         Environment: n/a
            Reporter: Steve Cohen
             Fix For: 3.1


When an HTTP 307 Redirect packet is returned to a Client using the latest 
source code, the following exception is thrown:

java.nio.charset.IllegalCharsetNameException: 
http://xxx.xxx.xxx.xxx:8080/lps/userRpc
 at java.nio.charset.Charset.checkName(Charset.java:305)
 at java.nio.charset.Charset.lookup(Charset.java:439)
 at java.nio.charset.Charset.forName(Charset.java:477)
 at java.lang.StringCoding$DecoderCache.makeDecoder(StringCoding.java:109)
 at java.lang.StringCoding$1.run(StringCoding.java:155)
 at java.security.AccessController.doPrivileged1(Native Method)
 at java.security.AccessController.doPrivileged(AccessController.java:351)
 at java.lang.StringCoding$DecoderCache.getDecoder(StringCoding.java(Compiled 
Code))
 at java.lang.StringCoding.getDecoder(StringCoding.java(Inlined Compiled Code))
 at java.lang.StringCoding.decode(StringCoding.java(Compiled Code))
 at java.lang.String.<init>(String.java(Compiled Code))
 at 
org.apache.commons.httpclient.util.EncodingUtil.getString(EncodingUtil.java:163)
 at 
org.apache.commons.httpclient.util.EncodingUtil.getString(EncodingUtil.java:186)
 at org.apache.commons.httpclient.URI.decode(URI.java:1769)
 at org.apache.commons.httpclient.URI.decode(URI.java:1723)
 at org.apache.commons.httpclient.URI.getHost(URI.java:2770)
 at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:106)
 at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:276)
 at 
org.apache.xmlrpc.client.XmlRpcCommonsTransport.resetClientForRedirect(XmlRpcCommonsTransport.java:177)
 at 
org.apache.xmlrpc.client.XmlRpcCommonsTransport.writeRequest(XmlRpcCommonsTransport.java:229)
 at 
org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:140)
 at 
org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
 at 
org.apache.xmlrpc.client.XmlRpcClientWorker$1.run(XmlRpcClientWorker.java:77)
 at java.lang.Thread.run(Thread.java:570)

It is not hard to see why this happens, looking at the source code which begins 
on line 173 of org.apache.xmlrpc.client.XmlRpcCommonsTransport:

173         try {
174             currentUri = method.getURI();
175             String charset = currentUri.getURI();
176             redirectUri = new URI(location, true, charset);
177             method.setURI(redirectUri);
178         } catch (URIException ex) {

On line 175, the currentUri.getURI() method is called, storing a string 
representation of the URI in the 
variable charset.  On line 176, the charset variable is fed into a new URI 
constructor, as a parameter that is supposed to represent the "the charset 
string to do escape encoding, if required".  Since this is a URI, and not the 
name of a valid charset, the exception is thrown.

I suppose this code must only have been tested when escape encoding was not 
required, so this wasn't seen before.  I will be including a patch to fix this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to