/**
* Should only be called from a synchronized method
*/
private MarshalledValueByteStream serialize0() {
MarshalledValueByteStream localRaw = raw;
if (localRaw == null) {
try {
// Do NOT set instance to null over here, since it may be used elsewhere (e.g., in a cache listener).
// this will be compacted by the MarshalledValueInterceptor when the call returns.
MarshalledValueByteStream baos = new ExpandableMarshalledValueByteStream(this.serialisedSize);
ObjectOutput out = marshaller.startObjectOutput(baos, true, this.serialisedSize);
try {
marshaller.objectToObjectStream(instance, out);
} finally {
marshaller.finishObjectOutput(out);
}
serialisedSize = baos.size();
localRaw = baos;
raw = baos;
} catch (Exception e) {
throw new CacheException("Unable to marshall value " + instance, e);
}