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;