Details
-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b71
-
generic
-
generic
-
Not verified
Description
Since the addition of Descriptors to all kinds of MBeanInfo (rather than just ModelMBeanInfo as before), an inconsistency has appeared in the serialization of MBeanFeatureInfo when its Descriptor is an empty ImmutableDescriptor.
MBeanFeatureInfo.writeObject(ObjectOutputStream out) does the following in this case:
out.write(1);
final String[] names = descriptor.getFieldNames();
out.writeObject(names);
out.writeObject(descriptor.getFieldValues(names));
MBeanFeatureInfo.readObject(ObjectInputStream in) does this:
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
if (names.length == 0) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
} else {
final Object[] values = (Object[])in.readObject();
descriptor = new ImmutableDescriptor(names, values);
}
The problem is that when names.length == 0 we do not read the zero-length Object[] written by out.writeObject(descriptor.getFieldValues(names)). The serialization specification is unclear as to what happens when a readObject does not consume all the "optional data". Native serialization (as used by RMI/JRMP) just discards the unread data, but RMI/IIOP implementations might not.
MBeanFeatureInfo.writeObject(ObjectOutputStream out) does the following in this case:
out.write(1);
final String[] names = descriptor.getFieldNames();
out.writeObject(names);
out.writeObject(descriptor.getFieldValues(names));
MBeanFeatureInfo.readObject(ObjectInputStream in) does this:
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
if (names.length == 0) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
} else {
final Object[] values = (Object[])in.readObject();
descriptor = new ImmutableDescriptor(names, values);
}
The problem is that when names.length == 0 we do not read the zero-length Object[] written by out.writeObject(descriptor.getFieldValues(names)). The serialization specification is unclear as to what happens when a readObject does not consume all the "optional data". Native serialization (as used by RMI/JRMP) just discards the unread data, but RMI/IIOP implementations might not.
Attachments
Issue Links
- duplicates
-
JDK-7027749 Wrong (de)serialization for the class javax.management.MBeanFeatureInfo
- Resolved
- relates to
-
JDK-8005309 Missed tests for 6783290,6937053,7009998
- Closed
-
JDK-8005472 com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.sh failed on windows
- Closed