use of org.apache.ignite.internal.marshaller.optimized.OptimizedObjectOutputStream in project ignite by apache.
the class OptimizedObjectStreamSelfTest method marshalUnmarshal.
/**
* Marshals and unmarshals object.
*
* @param obj Original object.
* @return Object after marshalling and unmarshalling.
* @throws Exception In case of error.
*/
private <T> T marshalUnmarshal(@Nullable Object obj) throws Exception {
OptimizedObjectOutputStream out = null;
OptimizedObjectInputStream in = null;
try {
out = OptimizedObjectStreamRegistry.out();
out.context(clsMap, CTX, null, true);
out.writeObject(obj);
byte[] arr = out.out().array();
in = OptimizedObjectStreamRegistry.in();
in.context(clsMap, CTX, null, getClass().getClassLoader());
in.in().bytes(arr, arr.length);
Object obj0 = in.readObject();
checkHandles(out, in);
return (T) obj0;
} finally {
OptimizedObjectStreamRegistry.closeOut(out);
OptimizedObjectStreamRegistry.closeIn(in);
}
}
Aggregations