You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Ioan Eugen Stan (JIRA)" <se...@james.apache.org> on 2013/03/01 08:05:12 UTC

[jira] [Commented] (JAMES-1473) Exception loop in James 3 mailet

    [ https://issues.apache.org/jira/browse/JAMES-1473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13590300#comment-13590300 ] 

Ioan Eugen Stan commented on JAMES-1473:
----------------------------------------

Deleting that line makes two tests fail. I'm not familiar enough with the code. Someone else?
                
> Exception loop in James 3 mailet
> --------------------------------
>
>                 Key: JAMES-1473
>                 URL: https://issues.apache.org/jira/browse/JAMES-1473
>             Project: James Server
>          Issue Type: Bug
>          Components: SpoolManager & Processors
>    Affects Versions: 3.0-beta5
>            Reporter: Ioan Eugen Stan
>            Assignee: Ioan Eugen Stan
>
> During my testing in JAMES beta 5 trunk I've found bug causing an exception loop when processing messages.
> To cause the loop throw an uncaught exception in any mailet without onMailetException=ignore attribute.
> After tracing through the code I think the problems with the handleException method in the ProcessorUtil class : 
>  /**
>      * This is a helper method that updates the state of the mail object to
>      * Mail.ERROR as well as recording the exception to the log
>      * 
>      * @param me
>      *            the exception to be handled
>      * @param mail
>      *            the mail being processed when the exception was generated
>      * @param offendersName
>      *            the matcher or mailet than generated the exception
>      * @param nextState
>      *            the next state to set
>      * 
>      * @throws MessagingException
>      *             thrown always, rethrowing the passed in exception <--- WHY REMOVE?
>      */
> public static void handleException(MessagingException me, Mail mail, String offendersName, String nextState, Logger logger) throws MessagingException {
>         
>         mail.setState(nextState);
>        
>         StringWriter sout = new StringWriter();
>         PrintWriter out = new PrintWriter(sout, true);
>         
>         StringBuffer exceptionBuffer = new StringBuffer(128).append("Exception calling ").append(offendersName).append(": ").append(me.getMessage());
>         
>         out.println(exceptionBuffer.toString());
>         
>         Exception e = me;
>         while (e != null) {
>             e.printStackTrace(out);
>             if (e instanceof MessagingException) {
>                 e = ((MessagingException) e).getNextException();
>             } else {
>                 e = null;
>             }
>         }
>         
>         String errorString = sout.toString();
>         
>         mail.setErrorMessage(errorString);
>         
>         logger.error(errorString);
>         
>         //This line should be removed
>         throw me; <--- REMOVE?
>     }
> If I remove the last statement re-throwing the MessagingException , the exception is logged then passed to the error processor configured in your mailetcontainer.xml, which to me is the correct behaviour.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org