Author: rdonkin
Date: Sat Jun 30 06:21:50 2007
New Revision: 552146
URL: http://svn.apache.org/viewvc?view=rev&rev=552146
Log:
Factory resets for ConditionManager and CommandStateManager into separate
method. Ensure reset called upon method termination so that thread local
variables are cleaned up.
Modified:
james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java
Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java
URL:
http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java?view=diff&rev=552146&r1=552145&r2=552146
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java
(original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/SieveFactory.java Sat
Jun 30 06:21:50 2007
@@ -121,47 +121,59 @@
throws SieveException
{
SieveParserVisitor visitor = new SieveParserVisitorImpl();
- ConditionManager.resetInstance();
- CommandStateManager.resetInstance();
+ reset();
try
{
- // Evaluate the Nodes
- startNode.jjtAccept(visitor, mail);
+ try
+ {
+ // Evaluate the Nodes
+ startNode.jjtAccept(visitor, mail);
- }
- catch (StopException ex)
- {
- // Stop is OK
- }
- catch (SieveException ex)
- {
- Log log = Logger.getLog();
- if (log.isErrorEnabled())
- log.error("Evaluation failed. Reason: " + ex.getMessage());
- if (log.isDebugEnabled())
- log.debug("Evaluation failed.", ex);
- throw ex;
- }
+ }
+ catch (StopException ex)
+ {
+ // Stop is OK
+ }
+ catch (SieveException ex)
+ {
+ Log log = Logger.getLog();
+ if (log.isErrorEnabled())
+ log.error("Evaluation failed. Reason: " + ex.getMessage());
+ if (log.isDebugEnabled())
+ log.debug("Evaluation failed.", ex);
+ throw ex;
+ }
- // If after evaluating all of the nodes or stopping, implicitKeep is
still
- // in effect, add a Keep to the list of Actions.
- if (CommandStateManager.getInstance().isImplicitKeep())
- mail.addAction(new ActionKeep());
+ // If after evaluating all of the nodes or stopping, implicitKeep
is still
+ // in effect, add a Keep to the list of Actions.
+ if (CommandStateManager.getInstance().isImplicitKeep())
+ mail.addAction(new ActionKeep());
- // Execute the List of Actions
- try
- {
- mail.executeActions();
- }
- catch (SieveException ex)
+ // Execute the List of Actions
+ try
+ {
+ mail.executeActions();
+ }
+ catch (SieveException ex)
+ {
+ Log log = Logger.getLog();
+ if (log.isErrorEnabled())
+ log.error("Evaluation failed. Reason: " + ex.getMessage());
+ if (log.isDebugEnabled())
+ log.debug("Evaluation failed.", ex);
+ throw ex;
+ }
+ }
+ finally
{
- Log log = Logger.getLog();
- if (log.isErrorEnabled())
- log.error("Evaluation failed. Reason: " + ex.getMessage());
- if (log.isDebugEnabled())
- log.debug("Evaluation failed.", ex);
- throw ex;
+ // Tidy up managers stored in thread local variables
+ reset();
}
+ }
+
+ private void reset() {
+ ConditionManager.resetInstance();
+ CommandStateManager.resetInstance();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]