Menu

#11 Try to cast Throwable into Exception

gilead4gwt
open-accepted
nobody
None
5
2010-04-29
2010-04-28
Anonymous
No

at net.sf.gilead.gwt.PersistentRemoteService.processCall(PersistentRemoteService.java:205) :

Exception exception = (Exception) GileadRPCHelper.parseReturnValue(e.getCause(), _beanManager);

you are trying to cast e.getCause() into Exception but if e is an Exception, e.getCause() can be an Error (and perhaps a Throwable).

I have chage the line below by :

Exception exception = (Exception) GileadRPCHelper.parseReturnValue(e, _beanManager);

and now I have the Expected Error, perhaps the correct correction should be to cast into a Throwable object, not sure.

Regards.

Discussion

  • Bruno Marchesson

    Hello,

    You are right, it can lead to an issue.
    It will be fixed for the next release.

    Regards
    Bruno

     
  • Bruno Marchesson

    • status: open --> open-accepted
     
  • Samuel Sjöberg

    Samuel Sjöberg - 2012-09-04

    Hi,
    The fix applied in trunk changed the original behavior. After the fix, the wrapping InvocationTargetException is returned to the client. If one exists, the underlying target exception should be returned for backwards compatibility.

    A fix for this could look like this:

    Throwable exception = e;
    if (e.getTargetException() != null) {
    exception = e.getTargetException();
    }

    // Clone exception if needed
    exception = (Throwable) GileadRPCHelper.parseReturnValue(exception, _beanManager);

    Regards,
    Samuel

     

Log in to post a comment.

MongoDB Logo MongoDB