On Mon, 6 Dec 2021 04:44:18 GMT, Jaikiran Pai <j...@openjdk.org> wrote:
>> The effects of invalid values of `jdk.serialFilter` and >> `jdk.serialFilterFactory` properties are >> incompletely specified. The behavior for invalid values of the properties is >> different and >> use an unconventional exception type, `ExceptionInInitializerError` and >> leave the `OIF.Config` class >> uninitialized. >> >> The exceptions in the `ObjectInputFilter.Config` class initialization caused >> by invalid values of the two properties, >> either by system properties supplied on the command line or security >> properties are logged. >> The `Config` class marks either or both the filter and filter factory values >> as unusable >> and remembers the exception message. >> >> Subsequent calls to the methods that get or set the filter or filter factory >> or create >> an `ObjectInputStream` throw `java.lang.IllegalStateException` with the >> remembered exception message. >> Constructing an `ObjectInputStream` calls both `Config.getSerialFilter` and >> `Config.getSerialFilterFactory`. >> The nature of the invalid property is reported as an `IllegalStateException` >> on first use. >> >> This PR supercedes https://github.com/openjdk/jdk/pull/6508 Document that >> setting an invalid property jdk.serialFilter disables deserialization > > src/java.base/share/classes/java/io/ObjectInputFilter.java line 859: > >> 857: /* >> 858: * Return message for an invalid filter factory configuration >> saved from the static init. >> 859: * It can be called before the static initializer is complete >> and has set the message/null. > > More of a curiosity than a review comment - Is that because the > `Config.getSerialFilterFactory()/setSerialFilterFactory(...)` could be called > from the constructor of the user configured factory class, which gets invoked > when static initialization is in progress for the `Config` class? Yes, it can be called before the `Config` class has completed initialization and `invalidFactoryMessage` may be seen as null. ------------- PR: https://git.openjdk.java.net/jdk/pull/6645