Class CheckingObjectOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ObjectOutputStream
-
- org.apache.wicket.core.util.objects.checker.CheckingObjectOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataOutput,java.io.Flushable,java.io.ObjectOutput,java.io.ObjectStreamConstants,java.lang.AutoCloseable
public class CheckingObjectOutputStream extends java.io.ObjectOutputStreamChecks an object tree during serialization for wrong state by delegating the work to the usedIObjectCheckers.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 usesIObjectCheckers to check the state of the object before serializing it. If the checker returnsIObjectChecker.Result.Status.FAILUREthen the serialization process is stopped and the error is logged.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCheckingObjectOutputStream.ObjectCheckException
-
Field Summary
-
Fields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, 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 Summary
Constructors Constructor Description CheckingObjectOutputStream(java.io.OutputStream outputStream, IObjectChecker... checkers)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static booleanisAvailable()Gets whether we can execute the tests.voidreset()protected java.lang.StringtoPrettyPrintedStack(java.lang.String type)Dump with indentation.protected voidwriteObjectOverride(java.lang.Object obj)-
Methods inherited from class java.io.ObjectOutputStream
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
-
-
-
-
Constructor Detail
-
CheckingObjectOutputStream
public CheckingObjectOutputStream(java.io.OutputStream outputStream, IObjectChecker... checkers) throws java.io.IOException, java.lang.SecurityExceptionConstructor.- Parameters:
outputStream- the output stream where the serialized object will be written upon successful checkcheckers- thecheckersthat will actually check the objects- Throws:
java.io.IOExceptionjava.lang.SecurityException
-
-
Method Detail
-
isAvailable
public static boolean isAvailable()
Gets whether we can execute the tests. If false, callingcheck(Object)will just return and you are advised to rely on theNotSerializableException. Clients are advised to call this method prior to calling the check method.- Returns:
- whether security settings and underlying API etc allow for accessing the serialization API using introspection
-
toPrettyPrintedStack
protected final java.lang.String toPrettyPrintedStack(java.lang.String type)
Dump with indentation.- Parameters:
type- the type that couldn't be serialized- Returns:
- A very pretty dump
-
writeObjectOverride
protected final void writeObjectOverride(java.lang.Object obj) throws java.io.IOException- Overrides:
writeObjectOverridein classjava.io.ObjectOutputStream- Throws:
java.io.IOException- See Also:
ObjectOutputStream.writeObjectOverride(java.lang.Object)
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.ObjectOutputStream- Throws:
java.io.IOException- See Also:
ObjectOutputStream.reset()
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.io.ObjectOutput- Overrides:
closein classjava.io.ObjectOutputStream- Throws:
java.io.IOException
-
-