jangidipramod / android-xmlrpc

Automatically exported from code.google.com/p/android-xmlrpc
0 stars 0 forks source link

Problem with fault reporting code in XMLRPCClient #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set up a new app using the libs
2. Try to connect to a working server (some kind of error occurs)
3. class cast (String) exceptions occur

What is the expected output? What do you see instead?
I would expect an exception to be raised but instead it crashes.

What version of the product are you using? On what operating system?
Ubuntu / android 2.2

Please provide any additional information below.

The code in XMLRPCClient includes this section:
else if (tag.equals(Tag.FAULT))
{
Log.d(TAG,CLASS+"Fault found :"+tag+" "+Tag.FAULT);
// fault response
pullParser.nextTag(); // Tag.VALUE (<value>)
// no parser.require() here since its called in
// XMLRPCSerializer.deserialize() below

// deserialize fault result
Map<String, Object> map = (Map<String, Object>) iXMLRPCSerializer
                        .deserialize(pullParser);
String faultString = (String) map.get(Tag.FAULT_STRING);
int faultCode = (Integer) map.get(Tag.FAULT_CODE);
entity.consumeContent();
throw new XMLRPCFault(faultString, faultCode);

However the faultString and faultCode are not being populated correctly and are 
causing cast exceptions.

I inserted some debugging code:
//hacks:)
Object os = map.get(Tag.FAULT_STRING);
Object oi = map.get(Tag.FAULT_CODE);
String faultString = (String)os;
String ois = (String)oi;
Log.d(TAG,CLASS+" String is :"+os+"  Int is :"+ois);

The contents was quite interesting:
XMLRPCClient String is :Traceback (most recent call last):
   File "/usr/share/pyshared/openerp-server/netsvc.py", line 489, in dispatch
     result = ExportService.getService(service_name).dispatch(method, auth, params)
   File "/usr/share/pyshared/openerp-server/service/web_services.py", line 590, in dispatch
     (db, uid, passwd ) = params[0:3]
 ValueError: need more than 2 values to unpack

Int is :need more than 2 values to unpack

Hence the class cast exception, the "need more than 2 values to unpack" is not 
easily represented by an integer error code. It appears that whatever fault is 
being found is not properly populating the fault codes, and is simply passing 
the exception up the error reporting chain. Ask Ariane 5 if that is a good idea 
:P

Original issue reported on code.google.com by MrC...@gmail.com on 5 Sep 2011 at 4:23