in protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/transport/DetachTypeDecoder.java [142:189]
private Detach readDetach(InputStream stream, StreamDecoder decoder, StreamDecoderState state, ListTypeDecoder listDecoder) throws DecodeException {
final Detach detach = new Detach();
@SuppressWarnings("unused")
final int size = listDecoder.readSize(stream, state);
final int count = listDecoder.readCount(stream, state);
if (count < MIN_DETACH_LIST_ENTRIES) {
throw new DecodeException("The handle field is mandatory in a Detach");
}
if (count > MAX_DETACH_LIST_ENTRIES) {
throw new DecodeException("To many entries in Detach list encoding: " + count);
}
for (int index = 0; index < count; ++index) {
// If the stream allows we peek ahead and see if there is a null in the next slot,
// if so we don't call the setter for that entry to ensure the returned type reflects
// the encoded state in the modification entry.
if (stream.markSupported()) {
stream.mark(1);
final boolean nullValue = ProtonStreamUtils.readByte(stream) == EncodingCodes.NULL;
if (nullValue) {
if (index == 0) {
throw new DecodeException("The handle field is mandatory");
}
continue;
} else {
ProtonStreamUtils.reset(stream);
}
}
switch (index) {
case 0:
detach.setHandle(decoder.readUnsignedInteger(stream, state, 0l));
break;
case 1:
detach.setClosed(decoder.readBoolean(stream, state, false));
break;
case 2:
detach.setError(decoder.readObject(stream, state, ErrorCondition.class));
break;
}
}
return detach;
}