//EOS intercepts the close() call and does not close the stream
EncryptionOutputStream eos = new EncryptionOutputStream(output);
CipherOutputStream cos = new CipherOutputStream(eos, cipher);
SerializationManager sm = SerializationStreamFactory.getManagerInstance(getSerializationType());
ObjectOutputStream oos = sm.createOutput(cos);
if(wrappedMarshaller != null)
{
if (wrappedMarshaller instanceof VersionedMarshaller)
((VersionedMarshaller) wrappedMarshaller).write(dataObject, oos, version);