james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ioan Eugen Stan (JIRA)" <server-...@james.apache.org>
Subject [jira] [Commented] (JAMES-1473) Exception loop in James 3 mailet
Date Fri, 01 Mar 2013 07:05:12 GMT

    [ 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


Mime
View raw message