// Clean up the stale messages in the write buffer.
synchronized (session.getWriteLock()) {
Object obj = session.getCurrentWrite();
if (obj != null) {
cause = new NetException("cleanUpWriteBuffer error");
session.getCurrentWriteBuffer().release();
session.resetCurrentWriteAndWriteBuffer();
fireExceptionCaught = true;
}
Queue<Object> writeBuffer = session.getWriteBuffer();
if (!writeBuffer.isEmpty()) {
// Create the exception only once to avoid the excessive
// overhead
// caused by fillStackTrace.
if (cause == null) {
cause = new NetException("cleanUpWriteBuffer error");
}
while (true) {
obj = writeBuffer.poll();
if (obj == null) {