public synchronized void serialize() {
if (raw == 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.
ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
ObjectOutput out = marshaller.startObjectOutput(baos, true);
try {
marshaller.objectToObjectStream(instance, out);
} finally {
marshaller.finishObjectOutput(out);
}
byte[] buf = baos.getRawBuffer();
int length = baos.size();
raw = new byte[length];
System.arraycopy(buf, 0, raw, 0, length);
} catch (Exception e) {
throw new CacheException("Unable to marshall value " + instance, e);
} finally {