XML-RPC

IllegalCharsetNameException thrown by XmlRpcCommonsTransport.resetClientForRedirect()

Created: 24/Jul/07 10:25 PM   Updated: 28/Nov/08 08:53 PM
Return to search
Component/s: Source
Affects Version/s: 3.1
Fix Version/s: 3.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works XMLRPC-144-patch.txt 2007-07-24 10:28 PM Steve Cohen 0.7 kB
Environment: n/a

Resolution Date: 25/Jul/07 06:17 AM


 Description  « Hide
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.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Steve Cohen made changes - 24/Jul/07 10:28 PM
Field Original Value New Value
Attachment XMLRPC-144-patch.txt [ 12362472 ]
Jochen Wiedmann made changes - 25/Jul/07 06:17 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Jochen Wiedmann made changes - 28/Nov/08 08:53 PM
Status Resolved [ 5 ] Closed [ 6 ]