If I call a method on the client that does not expect on the server, I
think it is perfectly reasonble for that to throw some kind of
exception. But I think it ought to be a clear exception that one
would expect to catch.
Here's what happens with rev 29:a1c0504b5811 if I call a method
(updatePushNotificationInfo) that does not exist on the server:
java.lang.reflect.UndeclaredThrowableException
at $Proxy0.updatePushNotificationInfo(Native Method)
... 3 more
Caused by: com.caucho.hessian.io.HessianServiceException: The service has no method named: updatePushNotificationInfo
at com.caucho.hessian.io.Hessian2Input.prepareFault(Unknown Source)
at com.caucho.hessian.io.Hessian2Input.startReply(Unknown Source)
at com.caucho.hessian.client.HessianProxy.invoke(Unknown Source)
at $Proxy0.updatePushNotificationInfo(Native Method)
... 3 more
I would think that a HessianServiceException would be a reasonable
thing to throw. I'm not entirely sure why (I'm not the familiar with
reflection), but as far as I can tell, I always get a
java.lang.reflect.UndeclaredThrowableException if I throw any kind of
declared exception. This is despite the fact that
HessianProxy.invoke() declares that it throws Throwable, and almost
every call to invoke() that I can find within the hessdroid library
declares that it throws IOException, except for the call in
JavaDeserializer.resolve() that declares that it throws Exception.
So it appears to me that my only recourse is to throw an undeclared
exception. See the attached patch. In HessianProxy.invoke() I'm
catching the HessianServiceException and re-throwing it as a
HessianRuntimeException. With this, I can now detect this situation
cleanly in my code by catching HessianRuntimeException, which seems to
me to be far better than UndeclaredThrowableException:
com.caucho.hessian.client.HessianRuntimeException: com.caucho.hessian.io.HessianServiceException: The service has no method named: updatePushNotificationInfo
at com.caucho.hessian.client.HessianProxy.invoke(Unknown Source)
at $Proxy0.updatePushNotificationInfo(Native Method)
... 3 more
Caused by: com.caucho.hessian.io.HessianServiceException: The service has no method named: updatePushNotificationInfo
at com.caucho.hessian.io.Hessian2Input.prepareFault(Unknown Source)
at com.caucho.hessian.io.Hessian2Input.startReply(Unknown Source)
at com.caucho.hessian.client.HessianProxy.invoke(Unknown Source)
at $Proxy0.updatePushNotificationInfo(Native Method)
... 3 more
Any thoughts? Is there any way to throw a non-RuntimeException in
this case? Are there any other unintended consequences of doing this
(like other cases for HessianServiceException where this might not be
appropriate?)
This is compiled on OSX 10.6.8 and running on Android 2.3.5, but I
doubt any of that matters.
Original issue reported on code.google.com by nospam...@yahoo.com on 13 Jan 2012 at 8:24
Original issue reported on code.google.com by
nospam...@yahoo.com
on 13 Jan 2012 at 8:24Attachments: