int messageLength = 0;
int messageStartReaderIndex = buffer.readerIndex();
try {
TNiftyTransport decodeAttemptTransport =
new TNiftyTransport(channel, buffer, ThriftTransportType.UNFRAMED);
int initialReadBytes = decodeAttemptTransport.getReadByteCount();
TProtocol inputProtocol =
inputProtocolFactory.getProtocol(decodeAttemptTransport);
// Skip through the message
inputProtocol.readMessageBegin();
TProtocolUtil.skip(inputProtocol, TType.STRUCT);
inputProtocol.readMessageEnd();
messageLength = decodeAttemptTransport.getReadByteCount() - initialReadBytes;
} catch (TTransportException | IndexOutOfBoundsException e) {
// No complete message was decoded: ran out of bytes
return null;
} finally {
if (buffer.readerIndex() - messageStartReaderIndex > maxFrameSize) {