james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1720573 - in /james/project/trunk: mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/ mpt/impl/managesieve/core/src/main/resources/org/apache/james/man...
Date Thu, 17 Dec 2015 14:55:56 GMT
Author: btellier
Date: Thu Dec 17 14:55:56 2015
New Revision: 1720573

URL: http://svn.apache.org/viewvc?rev=1720573&view=rev
Log:
JAMES-1618 Add a LOGOUT command - RFC-5804 compliant

Added:
    james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/LogoutTest.java
    james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/SessionTerminatedException.java
Modified:
    james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ManageSieveSession.java
    james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/Session.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Logout.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/util/SettableSession.java
    james/project/trunk/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveChannelUpstreamHandler.java

Modified: james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ManageSieveSession.java
URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ManageSieveSession.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ManageSieveSession.java
(original)
+++ james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/host/ManageSieveSession.java
Thu Dec 17 14:55:56 2015
@@ -20,17 +20,22 @@
 package org.apache.james.mpt.host;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.managesieve.transcode.ManageSieveProcessor;
 import org.apache.james.managesieve.util.SettableSession;
 import org.apache.james.mpt.api.Continuation;
 import org.apache.james.mpt.api.Session;
 import org.apache.james.mpt.helper.ByteBufferInputStream;
 import org.apache.james.mpt.helper.ByteBufferOutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.StringWriter;
 
 public class ManageSieveSession implements Session {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ManageSieveSession.class);
+
     private ByteBufferOutputStream out;
     private ByteBufferInputStream in;
     private ManageSieveProcessor manageSieveProcessor;
@@ -47,10 +52,16 @@ public class ManageSieveSession implemen
     @Override
     public String readLine() throws Exception {
         if (!isReadLast) {
+            String response;
             StringWriter stringWriter = new StringWriter();
             IOUtils.copy(in, stringWriter);
             String request = stringWriter.toString();
-            String response = manageSieveProcessor.handleRequest(settableSession, request);
+            try {
+                response = manageSieveProcessor.handleRequest(settableSession, request);
+            } catch (SessionTerminatedException e) {
+                LOGGER.info("Session is terminated");
+                response = "OK channel is closing\r\n";
+            }
             out.write(response);
             isReadLast = true;
         }

Added: james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/LogoutTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/LogoutTest.java?rev=1720573&view=auto
==============================================================================
--- james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/LogoutTest.java
(added)
+++ james/project/trunk/mpt/impl/managesieve/core/src/main/java/org/apache/james/mpt/testsuite/LogoutTest.java
Thu Dec 17 14:55:56 2015
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mpt.testsuite;
+
+import com.google.inject.Inject;
+import org.apache.james.mpt.host.ManageSieveHostSystem;
+import org.junit.Test;
+
+import java.util.Locale;
+
+public class LogoutTest extends ManageSieveMPTTest {
+
+    @Inject
+    private static ManageSieveHostSystem hostSystem;
+
+    public LogoutTest() throws Exception {
+        super(hostSystem);
+    }
+
+    @Test
+    public void logoutShouldWork() throws Exception {
+        scriptTest("logout", Locale.US);
+    }
+}

Added: james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test
URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test?rev=1720573&view=auto
==============================================================================
--- james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test
(added)
+++ james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/logout.test
Thu Dec 17 14:55:56 2015
@@ -0,0 +1,21 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you under the Apache License, Version 2.0 (the            #
+# "License"); you may not use this file except in compliance   #
+# with the License.  You may obtain a copy of the License at   #
+#                                                              #
+#   http://www.apache.org/licenses/LICENSE-2.0                 #
+#                                                              #
+# Unless required by applicable law or agreed to in writing,   #
+# software distributed under the License is distributed on an  #
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       #
+# KIND, either express or implied.  See the License for the    #
+# specific language governing permissions and limitations      #
+# under the License.                                           #
+################################################################
+
+C: LOGOUT
+S: OK channel is closing
\ No newline at end of file

Modified: james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
(original)
+++ james/project/trunk/mpt/impl/managesieve/file/src/test/java/org/apache/james/mpt/managesieve/file/ManageSieveFileTest.java
Thu Dec 17 14:55:56 2015
@@ -19,6 +19,7 @@
 
 package org.apache.james.mpt.managesieve.file;
 
+import org.apache.james.mpt.testsuite.LogoutTest;
 import org.apache.james.mpt.testsuite.NoopTest;
 import org.apache.james.mpt.testsuite.UnauthenticatedTest;
 import org.apache.onami.test.OnamiSuite;
@@ -30,7 +31,8 @@ import org.junit.runners.Suite;
 @RunWith(OnamiSuite.class)
 @Suite.SuiteClasses({
     NoopTest.class,
-    UnauthenticatedTest.class
+    UnauthenticatedTest.class,
+    LogoutTest.class
 })
 public class ManageSieveFileTest {
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/Session.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/Session.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/Session.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/Session.java
Thu Dec 17 14:55:56 2015
@@ -24,10 +24,14 @@ public interface Session {
 
     boolean isAuthenticated();
 
+    boolean isTerminated();
+
     String getUser();
 
     void setAuthentication(boolean isAuthenticated);
 
     void setUser(String user);
 
+    void markSessionAsTerminated();
+
 }

Added: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/SessionTerminatedException.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/SessionTerminatedException.java?rev=1720573&view=auto
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/SessionTerminatedException.java
(added)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/SessionTerminatedException.java
Thu Dec 17 14:55:56 2015
@@ -0,0 +1,24 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.james.managesieve.api;
+
+public class SessionTerminatedException extends ManageSieveException {
+}

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
Thu Dec 17 14:55:56 2015
@@ -26,6 +26,6 @@ package org.apache.james.managesieve.api
  * @see <a href=http://tools.ietf.org/html/rfc5804#section-2>RFC 5804 Commands</a>
  */
 public interface CoreCommands extends Capability, CheckScript, DeleteScript, GetScript, HaveSpace,
-        ListScripts, PutScript, RenameScript, SetActive, GetActive, Noop, Unauthenticate
{
+        ListScripts, PutScript, RenameScript, SetActive, GetActive, Noop, Unauthenticate,
Logout {
 
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Logout.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Logout.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Logout.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Logout.java
Thu Dec 17 14:55:56 2015
@@ -20,12 +20,13 @@
 
 package org.apache.james.managesieve.api.commands;
 
+import org.apache.james.managesieve.api.SessionTerminatedException;
 
 /**
  *  @see <a href=http://tools.ietf.org/html/rfc5804#section-2.3>RFC 5804 LOGOUT Command</a>
  */
 public interface Logout {
     
-    void logout();
+    void logout() throws SessionTerminatedException;
 
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
Thu Dec 17 14:55:56 2015
@@ -27,6 +27,7 @@ import org.apache.commons.io.IOUtils;
 import org.apache.james.managesieve.api.AuthenticationRequiredException;
 import org.apache.james.managesieve.api.ManageSieveRuntimeException;
 import org.apache.james.managesieve.api.Session;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.managesieve.api.SieveParser;
 import org.apache.james.managesieve.api.SyntaxException;
 import org.apache.james.managesieve.api.commands.CoreCommands;
@@ -192,6 +193,11 @@ public class CoreProcessor implements Co
         }
     }
 
+    @Override
+    public void logout() throws SessionTerminatedException {
+        throw new SessionTerminatedException();
+    }
+
     protected void authenticationCheck(Session session) throws AuthenticationRequiredException
{
         ensureUser(session);
         if (!session.isAuthenticated()) {

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
Thu Dec 17 14:55:56 2015
@@ -24,6 +24,7 @@ import com.google.common.base.Strings;
 import org.apache.james.managesieve.api.ArgumentException;
 import org.apache.james.managesieve.api.AuthenticationRequiredException;
 import org.apache.james.managesieve.api.Session;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.managesieve.api.SyntaxException;
 import org.apache.james.managesieve.api.commands.Capability.Capabilities;
 import org.apache.james.managesieve.api.commands.CoreCommands;
@@ -70,6 +71,10 @@ public class LineToCore{
             return "NO UNAUTHENTICATE do not take arguments";
         }
     }
+
+    public void logout() throws SessionTerminatedException {
+        core.logout();
+    }
     
     public void deleteScript(Session session, String args) throws AuthenticationRequiredException,
ScriptNotFoundException, IsActiveException, ArgumentException {
         String scriptName = ParserUtils.getScriptName(args);

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
Thu Dec 17 14:55:56 2015
@@ -23,6 +23,7 @@ package org.apache.james.managesieve.tra
 import org.apache.james.managesieve.api.ArgumentException;
 import org.apache.james.managesieve.api.AuthenticationRequiredException;
 import org.apache.james.managesieve.api.Session;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.managesieve.api.SyntaxException;
 import org.apache.james.managesieve.api.commands.Capability.Capabilities;
 import org.apache.james.sieverepository.api.ScriptSummary;
@@ -77,6 +78,10 @@ public class LineToCoreToLine {
         return lineToCore.unauthenticate(session, args);
     }
 
+    public void logout() throws SessionTerminatedException {
+        lineToCore.logout();
+    }
+
     public String checkScript(Session session, String args) {
         try {
             List<String> warnings = lineToCore.checkScript(session, args);

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
Thu Dec 17 14:55:56 2015
@@ -22,6 +22,7 @@ package org.apache.james.managesieve.tra
 
 import org.apache.james.managesieve.api.ManageSieveException;
 import org.apache.james.managesieve.api.Session;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.sieverepository.api.exception.SieveRepositoryException;
 
 public class ManageSieveProcessor {
@@ -79,7 +80,7 @@ public class ManageSieveProcessor {
         }
     }
 
-    private String matchCommandWithImplementation(Session session, String arguments, String
command) {
+    private String matchCommandWithImplementation(Session session, String arguments, String
command) throws SessionTerminatedException {
         if (command.equals(AUTHENTICATE)) {
             return "NO AUTHENTICATE command not yet implemented";
         } else if (command.equals(CAPABILITY)) {
@@ -97,7 +98,7 @@ public class ManageSieveProcessor {
         } else if (command.equals(LISTSCRIPTS)) {
             return lineToCoreToLine.listScripts(session, arguments);
         } else if (command.equals(LOGOUT)) {
-            return "NO LOGOUT command not yet implemented";
+            lineToCoreToLine.logout();
         } else if (command.equals(NOOP)) {
             return lineToCoreToLine.noop(arguments);
         } else if (command.equals(PUTSCRIPT)) {
@@ -110,9 +111,8 @@ public class ManageSieveProcessor {
             return "NO STARTTLS command not yet implemented";
         } else if (command.equals(UNAUTHENTICATE)) {
             return lineToCoreToLine.unauthenticate(session, arguments);
-        } else {
-            return "NO unknown " + command + " command";
         }
+        return "NO unknown " + command + " command";
     }
 
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/util/SettableSession.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/util/SettableSession.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/util/SettableSession.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/util/SettableSession.java
Thu Dec 17 14:55:56 2015
@@ -26,9 +26,11 @@ public class SettableSession implements
 
     private String user;
     private boolean isAuthenticated;
+    private boolean isTerminated;
 
     public SettableSession() {
         this.isAuthenticated = false;
+        this.isTerminated = false;
     }
 
     public String getUser() {
@@ -48,4 +50,13 @@ public class SettableSession implements
         this.user = user;
     }
 
+    @Override
+    public boolean isTerminated() {
+        return isTerminated;
+    }
+
+    @Override
+    public void markSessionAsTerminated() {
+        isTerminated = true;
+    }
 }

Modified: james/project/trunk/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveChannelUpstreamHandler.java
URL: http://svn.apache.org/viewvc/james/project/trunk/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveChannelUpstreamHandler.java?rev=1720573&r1=1720572&r2=1720573&view=diff
==============================================================================
--- james/project/trunk/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveChannelUpstreamHandler.java
(original)
+++ james/project/trunk/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveChannelUpstreamHandler.java
Thu Dec 17 14:55:56 2015
@@ -20,6 +20,7 @@
 package org.apache.james.managesieveserver.netty;
 
 import org.apache.james.managesieve.api.Session;
+import org.apache.james.managesieve.api.SessionTerminatedException;
 import org.apache.james.managesieve.transcode.ManageSieveProcessor;
 import org.apache.james.managesieve.util.SettableSession;
 import org.apache.james.protocols.api.logger.ProtocolLoggerAdapter;
@@ -66,18 +67,23 @@ public class ManageSieveChannelUpstreamH
 
         if (e.getCause() instanceof TooLongFrameException) {
             // Max line length exceeded
-            //
             // See also JAMES-1190
             ((ChannelManageSieveResponseWriter)ctx.getAttachment()).write("NO Maximum command
line length exceeded");
+        } else if (e.getCause() instanceof SessionTerminatedException) {
+            ((ChannelManageSieveResponseWriter)ctx.getAttachment()).write("OK channel is
closing");
+            logout(ctx);
         } else {
-            // logout on error not sure if that is the best way to handle it
-            attributes.remove(ctx.getChannel());
+            logout(ctx);
+        }
+    }
 
-            // Make sure we close the channel after all the buffers were flushed out
-            Channel channel = ctx.getChannel();
-            if (channel.isConnected()) {
-                channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
-            }
+    private void logout(ChannelHandlerContext ctx) {
+        // logout on error not sure if that is the best way to handle it
+        attributes.remove(ctx.getChannel());
+        // Make sure we close the channel after all the buffers were flushed out
+        Channel channel = ctx.getChannel();
+        if (channel.isConnected()) {
+            channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
         }
     }
 



---------------------------------------------------------------------
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