@Test public void testDecodeResponseContainingIncompleteTypeHeader() throws Exception { boolean result = decoder.doDecode(null, IoBuffer.wrap(new byte[]{(byte) 0x82}), mockedOutput); Assert.assertFalse(result); }
protected boolean doDecode(IoSession session, IoBuffer responseBuffer, ProtocolDecoderOutput decoder) throws Exception { int tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } int remaining = responseBuffer.remaining(); int initialLimit = responseBuffer.limit(); while (remaining >= tlvLength) { int limit = responseBuffer.position() + tlvLength; responseBuffer.limit(limit); KSITCPTransaction transaction = KSITCPTransaction.fromResponse(responseBuffer.slice()); decoder.write(transaction); responseBuffer.limit(initialLimit); responseBuffer.position(limit); if (remaining == tlvLength) { return true; } remaining = responseBuffer.remaining(); tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } } return false; }
TransactionDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer responseBuffer, ProtocolDecoderOutput decoder) throws Exception { int tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } int remaining = responseBuffer.remaining(); int initialLimit = responseBuffer.limit(); while (remaining >= tlvLength) { int limit = responseBuffer.position() + tlvLength; responseBuffer.limit(limit); KSITCPTransaction transaction = KSITCPTransaction.fromResponse(responseBuffer.slice()); decoder.write(transaction); responseBuffer.limit(initialLimit); responseBuffer.position(limit); if (remaining == tlvLength) { return true; } remaining = responseBuffer.remaining(); tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } } return false; } }
TransactionDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer responseBuffer, ProtocolDecoderOutput decoder) throws Exception { int tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } int remaining = responseBuffer.remaining(); int initialLimit = responseBuffer.limit(); while (remaining >= tlvLength) { int limit = responseBuffer.position() + tlvLength; responseBuffer.limit(limit); KSITCPTransaction transaction = KSITCPTransaction.fromResponse(responseBuffer.slice()); decoder.write(transaction); responseBuffer.limit(initialLimit); responseBuffer.position(limit); if (remaining == tlvLength) { return true; } remaining = responseBuffer.remaining(); tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } } return false; }  }
TransactionDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer responseBuffer, ProtocolDecoderOutput decoder) throws Exception { int tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } int remaining = responseBuffer.remaining(); int initialLimit = responseBuffer.limit(); while (remaining >= tlvLength) { int limit = responseBuffer.position() + tlvLength; responseBuffer.limit(limit); KSITCPTransaction transaction = KSITCPTransaction.fromResponse(responseBuffer.slice()); decoder.write(transaction); responseBuffer.limit(initialLimit); responseBuffer.position(limit); if (remaining == tlvLength) { return true; } remaining = responseBuffer.remaining(); tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } } return false; }   }
TransactionDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer responseBuffer, ProtocolDecoderOutput decoder) throws Exception { int tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } int remaining = responseBuffer.remaining(); int initialLimit = responseBuffer.limit(); while (remaining >= tlvLength) { int limit = responseBuffer.position() + tlvLength; responseBuffer.limit(limit); KSITCPTransaction transaction = KSITCPTransaction.fromResponse(responseBuffer.slice()); decoder.write(transaction); responseBuffer.limit(initialLimit); responseBuffer.position(limit); if (remaining == tlvLength) { return true; } remaining = responseBuffer.remaining(); tlvLength = extractNextTlvElementLength(responseBuffer); if (tlvLength == NOT_ENOUGH_DATA) { return false; } } return false; }    }