/** * Deserialize one event from the specified stream. * This expects the stream to be open and won't close it. The specified deserializer should take care of this. * * @param in inputstream to read * @param deserializer deserializer responsible to open/close the stream * @throws IOException generic I/O Exception */ public ThriftEnvelopeEvent(final InputStream in, final ThriftEnvelopeDeserializer deserializer) throws IOException { this.deserializer = deserializer; deserializeFromStream(in); }
@Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { final int numBytes = in.readInt(); final byte[] fullPayload = new byte[numBytes]; in.readFully(fullPayload); final ByteArrayInputStream inputBuffer = new ByteArrayInputStream(fullPayload, 0, fullPayload.length); deserializer.open(inputBuffer); deserializeFromStream(inputBuffer); deserializer.close(); }