in core/src/main/java/org/apache/mina/session/AbstractIoSession.java [646:697]
public void processMessageReceived(ByteBuffer message) {
if (IS_DEBUG) {
LOG.debug("processing message '{}' received event for session {}", message, this);
}
tl.set(message);
try {
// save basic statistics
readBytes += message.remaining();
lastReadTime = System.currentTimeMillis();
if (chain.length < 1) {
if (IS_DEBUG) {
LOG.debug("Nothing to do, the chain is empty");
}
IoHandler handler = getService().getIoHandler();
if (handler != null) {
IoHandlerExecutor executor = getService().getIoHandlerExecutor();
if (executor != null) {
// asynchronous event
// copy the bytebuffer
if (IS_DEBUG) {
LOG.debug("copying bytebuffer before pushing to the executor");
}
ByteBuffer original = message;
ByteBuffer clone = ByteBuffer.allocate(original.capacity());
// copy from the beginning
original.rewind();
clone.put(original);
original.rewind();
clone.flip();
executor.execute(new ReceiveEvent(this, clone));
} else {
// synchronous call (in the I/O loop)
handler.messageReceived(this, message);
}
}
} else {
readChainPosition = 0;
// we call the first filter, it's supposed to call the next ones using the filter chain controller
chain[readChainPosition].messageReceived(this, message, this);
}
} catch (RuntimeException e) {
processException(e);
}
}