On Tue 16 Jul 2013 03:01:09 AM CEST, David Holmes wrote: > On 15/07/2013 6:41 PM, Jaroslav Bachorik wrote: >> Please, review the patch for >> https://jbs.oracle.com/bugs/browse/JDK-8019584 >> >> http://cr.openjdk.java.net/~jbachorik/8019584/webrev.00/ >> >> The reason for the failure is that the ObjectInputStream.readFields() >> method does not throw CNFE as specified when encountering instances of >> unknown in the object graph to be deserialized. Instead, it leaves the >> fields in the default state which in this case is "null" and is not >> valid. Hence, the deserialization validation fails. >> >> Since the main cause is in the RMI code, has been there for very long >> time and changing the behaviour there might have disrupting effects on >> various 3rd party applications I decided to work around this problem in >> the JMX code. > > Can you pinpoint the code that actually fails to propagate the > ClassNotFoundException - I don't see any issue in OIS.readFields > itself so this comes from elsewhere. Failing to throw CNFE when > deserializing seems like a major bug to me.
Yes, I agree. When you take a look at the ObjectInputStream.defaultReadObject() you can see that it forwards any captured exception on the lines 509-512 --- ClassNotFoundException ex = handles.lookupException(passHandle); if (ex != null) { throw ex; } --- On the other hand the GetFieldImpl just nulifies the read field on lines 2137-2138 --- return (handles.lookupException(objHandle) == null) ? objVals[off] : null; -- and the ObjectInputStream.readFields() completely disregards the "handles" map and basically swallows any exception discovered during the fields deserialization, AFAIK. -JB- and the ObjectInputStream.readFields > > Thanks, > David > > >> The workaround adds InvalidObjectException to the list of expected >> exceptions when processing JMX notifications. It is treated the same way >> as eg. CNFE - the exception is logged and the notification will be >> reported as missing. This will resolve the problem on the JMX side. >> >> Thanks, >> >> -JB- >>