Class RefusingObjectInputStream

java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
de.aristaflow.adept2.util.injection.RefusingObjectInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

public final class RefusingObjectInputStream extends ObjectInputStream
An ObjectInputStream refusing InjectionAware objects: a stream without a driver cannot re-bind the collaborators of such an object, so it must not hand it out with silently null fields. This turns "fail open" into a loud error at the offending call site.

The refusal is graph-deep, an InjectionAware object buried inside a plain-data graph is caught as well. It only reaches the objects the stream actually reads, though: one that a readObject of a class constructs is passed to no per-object seam and arrives un-injected on every path – which is why an object needing an environment is obtained in afterInjection, never built in readObject.

  • Constructor Details

    • RefusingObjectInputStream

      public RefusingObjectInputStream(InputStream in) throws IOException
      Creates a refusing stream reading from the designated input stream.
      Parameters:
      in - The input stream to read the objects from.
      Throws:
      IOException - If the header of the designated input stream cannot be read, an IOException will be thrown.
  • Method Details