/****************************************************************
 * 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.protocols.impl;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.channel.group.ChannelGroup;

/**
 * Add channels to the channel group after the channel was opened
 *
 */
@ChannelPipelineCoverage("all")
public final class ChannelGroupHandler extends SimpleChannelUpstreamHandler {
    private ChannelGroup channels;
    public ChannelGroupHandler(ChannelGroup channels) {
        this.channels = channels;
    }
    
    public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
        // Add all open channels to the global group so that they are
        // closed on shutdown.
        channels.add(e.getChannel());
    }

}
@@ -1819,17 +1819,30 @@
    %7D%0A   
- 
+%0A    @Override
 %0A    pub
@@ -1910,16 +1910,32 @@
 vent e) 
+throws Exception
 %7B%0A      
@@ -2067,16 +2067,106 @@
 nel());%0A
+        %0A        // call the next handler in the chain%0A        super.channelOpen(ctx, e);%0A
     %7D%0A%0A%7D

Call the next handler in the chain after adding channel to channelgroup (JAMES-1014)