use of org.apache.ignite.internal.binary.streams.BinaryHeapInputStream in project ignite by apache.
the class BinaryMarshallerSelfTest method testReadDetachObjectProperly.
/**
* Perform action on binary object after unmarshalling from offheap data, when offheap memory chunk cleared.
*
* @param obj Object to marshal-unmarshal.
* @param action Action to perform on object.
* @throws Exception If failed.
*/
private void testReadDetachObjectProperly(Object obj, IgniteThrowableConsumer<Object> action, boolean deserialize) throws Exception {
BinaryMarshaller marsh = binaryMarshaller();
BinaryHeapOutputStream os = new BinaryHeapOutputStream(1024);
BinaryWriterExImpl writer = marsh.binaryMarshaller().writer(os);
writer.writeObject(obj);
BinaryHeapInputStream is = new BinaryHeapInputStream(os.array());
BinaryReaderExImpl reader = marsh.binaryMarshaller().reader(is);
Object bObj = reader.readObjectDetached(deserialize);
Arrays.fill(os.array(), (byte) 0);
action.accept(bObj);
}
Aggregations