Title: Modified ReflectiveXmlRpcHandlerto throw proper XmlRpcException

I am using the XML-RPC as a Servlet.

What bothers me is that when I throw an XmlRpcExption in the actual Handler with a specific error code, it get caught on the way, and becomes a defautl XmlRPCException with the error code 0 and several error message concatenated.

I then modified the invoke(Object pInstance, Method pMethod, Object[] pArgs) method in ReflectiveXmlRpcHandler

So if the call to  pMethod.invoke(pInstance, pArgs);
throws an XmlRpcException, it would then only relays it

So it is something like this

} catch (InvocationTargetException e) {
            Throwable t = e.getCause();
            if (t instanceof XmlRpcException) {
                throw (XmlRpcException) t;
           }
        throw new XmlRpcException("Failed to invoke method "
                                          + pMethod.getName() + " in class "
                                          + clazz.getName() + ": "
                                          + t.getMessage(), t);
}

I attached the patch agains the 3.0 tagged version.

<<xmlrpc-server-patch.txt>>
I did this quickly, so opinion and flame are very welcome!!

Index: C:/Mes documents/dev/workspace/XmlRPC 
3.0/server/src/main/java/org/apache/xmlrpc/server/ReflectiveXmlRpcHandler.java
===================================================================
--- C:/Mes documents/dev/workspace/XmlRPC 
3.0/server/src/main/java/org/apache/xmlrpc/server/ReflectiveXmlRpcHandler.java  
      (revision 452591)
+++ C:/Mes documents/dev/workspace/XmlRPC 
3.0/server/src/main/java/org/apache/xmlrpc/server/ReflectiveXmlRpcHandler.java  
      (working copy)
@@ -118,7 +118,10 @@
                                          + pMethod.getName() + " in class "
                                          + clazz.getName(), e);
            } catch (InvocationTargetException e) {
-               Throwable t = e.getTargetException();
+            Throwable t = e.getCause();
+            if (t instanceof XmlRpcException) {
+                throw (XmlRpcException) t;
+            }
                throw new XmlRpcException("Failed to invoke method "
                                          + pMethod.getName() + " in class "
                                          + clazz.getName() + ": "
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to