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 no...@apache.org on 2011/10/27 12:11:55 UTC

svn commit: r1189698 - /james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java

Author: norman
Date: Thu Oct 27 10:11:55 2011
New Revision: 1189698

URL: http://svn.apache.org/viewvc?rev=1189698&view=rev
Log:
Make sure the LineHandler is removed from the session once the extensions were processed. See PROTOCOLS-44

Modified:
    james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java

Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java?rev=1189698&r1=1189697&r2=1189698&view=diff
==============================================================================
--- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java (original)
+++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/DataLineMessageHookHandler.java Thu Oct 27 10:11:55 2011
@@ -67,6 +67,7 @@ public class DataLineMessageHookHandler 
                 out.close();
                 
                 Response response = processExtensions(session, env);
+                session.popLineHandler();
                 session.resetState();
                 return response;
                 
@@ -99,46 +100,43 @@ public class DataLineMessageHookHandler 
      * @param session
      */
     protected Response processExtensions(SMTPSession session, MailEnvelopeImpl mail) {
-        try {
+       
 
-            if (mail != null && messageHandlers != null) {
-                int count = messageHandlers.size();
-                for (int i = 0; i < count; i++) {
-                    MessageHook rawHandler = (MessageHook) messageHandlers.get(i);
-                    session.getLogger().debug("executing message handler " + rawHandler);
-
-                    long start = System.currentTimeMillis();
-                    HookResult hRes = rawHandler.onMessage(session, mail);
-                    long executionTime = System.currentTimeMillis() - start;
-
-                    if (rHooks != null) {
-                        for (int i2 = 0; i2 < rHooks.size(); i2++) {
-                            Object rHook = rHooks.get(i2);
-                            session.getLogger().debug("executing hook " + rHook);
+        if (mail != null && messageHandlers != null) {
+            int count = messageHandlers.size();
+            for (int i = 0; i < count; i++) {
+                MessageHook rawHandler = (MessageHook) messageHandlers.get(i);
+                session.getLogger().debug("executing message handler " + rawHandler);
+
+                long start = System.currentTimeMillis();
+                HookResult hRes = rawHandler.onMessage(session, mail);
+                long executionTime = System.currentTimeMillis() - start;
+
+                if (rHooks != null) {
+                    for (int i2 = 0; i2 < rHooks.size(); i2++) {
+                        Object rHook = rHooks.get(i2);
+                        session.getLogger().debug("executing hook " + rHook);
 
-                            hRes = ((HookResultHook) rHook).onHookResult(session, hRes, executionTime, rawHandler);
-                        }
+                        hRes = ((HookResultHook) rHook).onHookResult(session, hRes, executionTime, rawHandler);
                     }
+                }
 
-                    SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(hRes);
+                SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(hRes);
 
-                    // if the response is received, stop processing of command
-                    // handlers
-                    if (response != null) {
-                        return response;
-                    }
+                // if the response is received, stop processing of command
+                // handlers
+                if (response != null) {
+                    return response;
                 }
+            }
 
-                // Not queue the message!
-                SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(new HookResult(HookReturnCode.DENY));
-                return response;
+            // Not queue the message!
+            SMTPResponse response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(new HookResult(HookReturnCode.DENY));
+            return response;
 
           
-            }
-        } finally {
-
-            session.popLineHandler();
         }
+        
         return null;
     }
 



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