[ 
https://issues.apache.org/jira/browse/XMLRPC-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13054477#comment-13054477
 ] 

Dmitry Katsubo commented on XMLRPC-154:
---------------------------------------

Sorry, updated version:

=== cut ===
--- XmlRpcResponseParser.java.orig      2011-06-24 16:12:19.049354800 +0200
+++ XmlRpcResponseParser.java   2011-06-24 16:41:59.826376700 +0200
@@ -58,12 +58,16 @@
                        super.setResult(pResult);
                } else {
                        Map map = (Map) pResult;
-                       Integer faultCode = (Integer) map.get("faultCode");
+                       Object faultCode = map.get("faultCode");
                        if (faultCode == null) {
                                throw new SAXParseException("Missing 
faultCode", getDocumentLocator());
                        }
                        try {
-                               errorCode = faultCode.intValue();
+                               if (faultCode instanceof Number) {
+                                       errorCode = ((Number) 
faultCode).intValue();
+                               } else {
+                                       errorCode = 
Integer.parseInt(faultCode.toString());
+                               }
                        } catch (NumberFormatException e) {
                                throw new SAXParseException("Invalid faultCode: 
" + faultCode,
                                                                                
        getDocumentLocator());
=== cut === 

> ClassCastException getting faultCode in XmlResponseParser.addResult
> -------------------------------------------------------------------
>
>                 Key: XMLRPC-154
>                 URL: https://issues.apache.org/jira/browse/XMLRPC-154
>             Project: XML-RPC
>          Issue Type: Bug
>          Components: Source
>    Affects Versions: 3.1
>         Environment: Windows server 2003
>            Reporter: Wes
>
> In 3.1 XmlRpcResponseParser.addResult(Object), the following unguarded code 
> throws a ClassCastException:
>                       Integer faultCode = (Integer) map.get("faultCode");
> The server (in this case Bugzilla::WebService::Bug::get_bugs.pm) might be 
> using the wrong type (String) for faultCode , but this exception hides the 
> true error being reported so it would be nice if the code were guarded.
> I'm using binaries from xmlrpc-3.1-bin.tar.gz.  
> (As an aside, I can't figure out what Object[] to send to get_bugs: neither 
> Integer nor String works.)
> java.lang.ClassCastException: java.lang.String incompatible with 
> java.lang.Integer
>       at 
> org.apache.xmlrpc.parser.XmlRpcResponseParser.addResult(XmlRpcResponseParser.java:58)
>       at 
> org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endValueTag(RecursiveTypeParserImpl.java:71)
>       at 
> org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponseParser.java:183)
>       at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>       at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
>       at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>       at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>       at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>       at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>       at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>       at 
> org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:175)
>       at 
> org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
>       at 
> org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
>       at 
> org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:44)
>       at 
> org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
>       at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
>       at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)
>       at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)
> Thanks,
> Wes

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to