// clear seems to cause a write to closed session ex in some cases
log.warn("Exception clearing write queue for {}", sessionId, ex);
}
}
// force close the session
final CloseFuture future = session.close(true);
IoFutureListener<CloseFuture> listener = new IoFutureListener<CloseFuture>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
public void operationComplete(CloseFuture future) {
// now connection should be closed
log.debug("Close operation completed {}: {}", sessionId, future.isClosed());
future.removeListener(this);
for (Object key : session.getAttributeKeys()) {
Object obj = session.getAttribute(key);
log.debug("Attribute: {}", obj.getClass().getName());
if (obj instanceof IoProcessor) {
log.debug("Flushing session in processor");
((IoProcessor) obj).flush(session);
log.debug("Removing session from processor");
((IoProcessor) obj).remove(session);
} else if (obj instanceof IoBuffer) {
log.debug("Clearing session buffer");
((IoBuffer) obj).clear();
((IoBuffer) obj).free();
}
}
}
};
future.addListener(listener);
}
}