[jboss-jira] [JBoss JIRA] Created: (JBPM-972) org.jbpm.graph.action.Script does not provide specific (correct) handling for bsh.TargetError

Olga Ivanova (JIRA) jira-events at lists.jboss.org
Tue May 22 14:20:02 EDT 2007


org.jbpm.graph.action.Script does not provide specific (correct) handling for bsh.TargetError
---------------------------------------------------------------------------------------------

                 Key: JBPM-972
                 URL: http://jira.jboss.com/jira/browse/JBPM-972
             Project: JBoss jBPM
          Issue Type: Bug
          Components: Core Engine
    Affects Versions: jBPM jPDL 3.2
            Reporter: Olga Ivanova
         Assigned To: Tom Baeyens


The recommended way of handling beanshel script TargerError is to use target exception (rethrow or printout), instead of using TargerError itself.
see (http://www.beanshell.org/manual/bshmanual.html).

The reason why this problem is reported is that when TargetError is not handled in a way it is proposed, stack trace where such error exists became inaccurate.
This happends if TargetError is a cause for some other error on which printStackTrace is called, and TargetError itself contains targer exception with it's own causes. In this case, only target exception itself is printed out, all it's cause exceptions are not printed. Unit Test is attached.


In JBPM org.jbpm.graph.action.Script , following code handles beanshell script exceptions (line 137):

    } catch (EvalError e) {
      log.warn("exception during evaluation of script expression", e);
      // try to throw the cause of the EvalError
      if (e.getCause() instanceof Exception) {
        throw (Exception) e.getCause();
      } else if (e.getCause() instanceof Error) {
        throw (Error) e.getCause();
      } else {
        throw e;
      }
    }

Which does not work as expected, as TargerError which extends EvalError always returns null from getCause method.
Another thing is that there are two child classes of EvalError - TargetError, which should be handled specially and ParseException, where no special handling is required.

The correct way of handling these exceptions could be following:
    } catch (EvalError e) {
      log.warn("exception during evaluation of script expression", e);
      if (e instanceof TargetError) {
        TargetError te = (TargetError)e;
        // try to throw the cause of the TargetError
        if (te.getTarget() instanceof Exception) {
          throw (Exception) te.getTarget();
        } else if (te.getTarget() instanceof Error) {
          throw (Error) te.getTarget();
        } 
      }
      throw e;



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list