in core/src/main/java/org/apache/mina/transport/nio/NioTcpSession.java [284:330]
private void processRead(final ByteBuffer readBuffer) {
try {
LOG.debug("readable session : {}", this);
// Read everything we can up to the buffer size
final int readCount = ((SocketChannel) channel).read(readBuffer);
LOG.debug("read {} bytes", readCount);
if (readCount < 0) {
// session closed by the remote peer
LOG.debug("session closed by the remote peer");
close(true);
} else if (readCount > 0) {
// we have read some data
// limit at the current position & rewind buffer back to start &
// push to the chain
readBuffer.flip();
if (isSecured()) {
// We are reading data over a SSL/TLS encrypted connection.
// Redirect the processing to the SslHelper class.
final SslHelper sslHelper = getAttribute(SSL_HELPER, null);
if (sslHelper == null) {
throw new IllegalStateException();
}
sslHelper.processRead(this, readBuffer);
// We don't clear the buffer. It has been done by the sslHelper
} else {
// Plain message, not encrypted : go directly to the chain
processMessageReceived(readBuffer);
// And now, clear the buffer
readBuffer.clear();
}
// Update the session idle status
idleChecker.sessionRead(this, System.currentTimeMillis());
}
} catch (final IOException e) {
LOG.error("Exception while reading : ", e);
processException(e);
}
}