@Override public void run() { for (Map.Entry<ChannelHandler, Collection<ChannelHandlerWriteSubscription>> entry : handlers.entrySet()) { ChannelHandler channelHandler = entry.getKey(); Collection<ChannelHandlerWriteSubscription> subscriptions = entry.getValue(); for (ChannelHandlerWriteSubscription subscription : subscriptions) { try { channelHandler.addWriter(subscription); } catch (Exception ex) { // If an error happens while adding the write subscription, // notify the appropriate handler subscription.getExceptionWriteFunction().writeValue(ex); } } } } });