use of org.mule.runtime.module.artifact.api.serializer.ArtifactClassLoaderObjectOutputStream in project mule by mulesoft.
the class CustomJavaSerializationProtocol method doSerialize.
/**
* {@inheritDoc}
*/
@Override
protected byte[] doSerialize(Object object) throws Exception {
// TODO: MULE-11939
if (object instanceof CursorStreamProvider) {
try (CursorStream cursor = ((CursorStreamProvider) object).openCursor()) {
object = toByteArray(cursor);
}
}
validateForSerialization(object);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(512);
try (ObjectOutputStream out = new ArtifactClassLoaderObjectOutputStream(classLoaderRepository, outputStream)) {
out.writeObject(object);
} catch (IOException ex) {
throw new SerializationException("Cannot serialize object", ex);
}
return outputStream.toByteArray();
}
Aggregations