You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/03/05 04:39:17 UTC

[GitHub] [james-project] chibenwa commented on a change in pull request #322: JAMES-3511 Solve java.util.NoSuchElementException: heartbeatHandler

chibenwa commented on a change in pull request #322:
URL: https://github.com/apache/james-project/pull/322#discussion_r588028541



##########
File path: server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
##########
@@ -183,20 +184,23 @@ private void disconnectClient(ChannelHandlerContext ctx) {
     }
 
     @Override
-    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+    public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
         try (Closeable closeable = IMAPMDCContext.from(ctx, attributes)) {
             imapCommandsMetric.increment();
             ImapSession session = (ImapSession) attributes.get(ctx.getChannel());
             ImapResponseComposer response = (ImapResponseComposer) ctx.getAttachment();
-            ImapMessage message = (ImapMessage) e.getMessage();
+            ImapMessage message = (ImapMessage) event.getMessage();
             ChannelPipeline cp = ctx.getPipeline();
 
             try {
-                if (cp.get(NettyConstants.EXECUTION_HANDLER) != null) {
-                    cp.addBefore(NettyConstants.EXECUTION_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);
-                } else {
-                    cp.addBefore(NettyConstants.CORE_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);
-
+                try {
+                    if (cp.get(NettyConstants.EXECUTION_HANDLER) != null) {
+                        cp.addBefore(NettyConstants.EXECUTION_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);
+                    } else {
+                        cp.addBefore(NettyConstants.CORE_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);
+                    }
+                } catch (IllegalArgumentException e) {
+                    LOGGER.info("heartbeat handler is already part of this pipeline", e);

Review comment:
       No because I want to proceed with the request.
   
   Moving it outside will result in a different behaviour.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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