public class CheckingObjectOutputStream extends ObjectOutputStream
IObjectChecker
s.
As this class depends heavily on JDK's serialization internals using introspection, analyzing may
not be possible, for instance when the runtime environment does not have sufficient rights to set
fields accessible that would otherwise be hidden. You should call
isAvailable()
to see whether this class can operate properly.
An ObjectOutputStream that uses IObjectChecker
s to check the
state of the object before serializing it. If the checker returns
IObjectChecker.Result.Status.FAILURE
then the serialization process is stopped and the error is logged.
Modifier and Type | Class and Description |
---|---|
static class |
CheckingObjectOutputStream.ObjectCheckException |
ObjectOutputStream.PutField
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
Constructor and Description |
---|
CheckingObjectOutputStream(OutputStream outputStream,
IObjectChecker... checkers)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static boolean |
isAvailable()
Gets whether we can execute the tests.
|
void |
reset() |
protected String |
toPrettyPrintedStack(String type)
Dump with indentation.
|
protected void |
writeObjectOverride(Object obj) |
annotateClass, annotateProxyClass, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeClassDescriptor, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeShort, writeStreamHeader, writeUnshared, writeUTF
public CheckingObjectOutputStream(OutputStream outputStream, IObjectChecker... checkers) throws IOException, SecurityException
outputStream
- the output stream where the serialized object will be written upon successful checkcheckers
- the checkers
that will actually check the objectsIOException
SecurityException
public static boolean isAvailable()
check(Object)
will just
return and you are advised to rely on the NotSerializableException
. Clients are
advised to call this method prior to calling the check method.protected final String toPrettyPrintedStack(String type)
type
- the type that couldn't be serializedprotected final void writeObjectOverride(Object obj) throws IOException
writeObjectOverride
in class ObjectOutputStream
IOException
ObjectOutputStream.writeObjectOverride(java.lang.Object)
public void reset() throws IOException
reset
in class ObjectOutputStream
IOException
ObjectOutputStream.reset()
public void close() throws IOException
close
in interface Closeable
close
in interface ObjectOutput
close
in interface AutoCloseable
close
in class ObjectOutputStream
IOException
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.