Bug 5118 - Unsent messages reported as failed after disconnect
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / connection / ConnectionAdapterImpl.java
index 37635c033122dbb96a1d67500665ad5806f8b855..7c10be16208c60cc6234336a2bffaa489703bd93 100644 (file)
@@ -203,7 +203,11 @@ public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics i
         outputManager = ret;
         /* we don't need it anymore */
         channel.pipeline().remove(output);
-        channel.pipeline().addLast(outputManager);
+        // OutboundQueueManager is put before DelegatingInboundHandler because otherwise channelInactive event would
+        // be first processed in OutboundQueueManager and then in ConnectionAdapter (and Openflowplugin). This might
+        // cause problems because we are shutting down the queue before Openflowplugin knows about it.
+        channel.pipeline().addBefore(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(),
+                PipelineHandlers.CHANNEL_OUTBOUND_QUEUE_MANAGER.name(), outputManager);
 
         return new OutboundQueueHandlerRegistrationImpl<T>(handler) {
             @Override