for (Runnable task: tasks) {
if (task instanceof ChannelEventRunnable) {
if (cause == null) {
cause = new IOException("Unable to process queued event");
}
ChannelEvent event = ((ChannelEventRunnable) task).getEvent();
event.getFuture().setFailure(cause);
if (channels == null) {
channels = new HashSet<Channel>();
}
// store the Channel of the event for later notification of the exceptionCaught event
channels.add(event.getChannel());
}
}
// loop over all channels and fire an exceptionCaught event
if (channels != null) {