United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6332962 : javax.managment.modelmbean.DescriptorSupport.writeObject() has problem validating serializability

Details
Type:
Bug
Submit Date:
2005-10-05
Status:
Resolved
Updated Date:
2011-01-27
Project Name:
JDK
Resolved Date:
2005-12-03
Component:
core-svc
OS:
windows_xp
Sub-Component:
javax.management
CPU:
other
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0u4
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
javax.managment.modelmbean.DescriptorSupport.writeObject() has problem validating the
serializability of the descriptor field values.

This is causing a jmx remote client which runs over rmi/iiop to fail when invoking
getMBeanInfo on the MBeanServerConnection.
OPERATING SYSTEM
Windows XP
FULL JDK VERSION
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode)
DESCRIPTION
javax.managment.modelmbean.DescriptorSupport.writeObject() should validate
the referenced objects are serializable before writing out the serialized form
Note: We don't really have a standalone testcase for this as the problem was discovered with WAS 7.0 setup
but know that if javax.managment.modelmbean.DescriptorSupport.writeObject() is updated
as described the problem goes away.

                                    

Comments
SUGGESTED FIX

Suggested fix is to remove the "targetObject" field from the HashMap that is included in the serial form of a DescriptorSupport.  This can be done by making some small changes to the existing writeObject method.
                                     
2005-10-18
EVALUATION

It turns out that the underlying problem is with the targetObject field.  This field can be used to direct an individual attribute or operation towards a different resource from the one defined for the Model MBean as a whole.  As such, its value is often a non-serializable object, and in any case it does not make sense to serialize it.  Therefore it would make sense to exclude it from the serialization of DescriptorSupport so that RequiredModelMBean.getMBeanInfo() returns a serializable object.
                                     
2005-10-18
EVALUATION

Nothing in the specification should lead anybody to suppose that a DescriptorSupport will be serializable if it contains a non-serializable object, any more than a HashMap is, for example.

Furthermore there is no way in general to tell whether an object is serializable other than by serializing it.  instanceof Serializable tells you nothing since (a) the object might have a writeObject that throws an exception (the recommended way for a subclass to be non-serializable if its parent is serializable), and (b) the object being serialized might itself be serializable but contain an object that is not, which indeed is exactly what we are seeing here with DescriptorSupport.

It appears that the code that is failing here is incorrect and I do not see any clean way of allowing it to work anyway.
                                     
2005-10-14
SUGGESTED FIX

Fix suggested by the submitter:

javax.managment.modelmbean.DescriptorSupport.writeObject() should validate
the referenced object's are serializable before writing out the serialized form
??
i.e. within the for loop prior to the line:
?????? descriptor.put() line have:
if (!(entry.getValue() instanceof java.io.Serializable)) continue;
                                     
2005-10-14
WORK AROUND

No workaround - other than not to use javax.management.modelmbean.DescriptorSupport with non-serializable objects
                                     
2005-10-05



Hardware and Software, Engineered to Work Together