JDK-6273765 : ImmutableDescriptor.getFieldValues(non-empty-array) on an empty descriptor returns unexpected array
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-20
  • Updated: 2017-05-16
  • Resolved: 2005-12-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b47Fixed
Description
modelmbean.DescriptorSupport behaves as expected but ImmutableDescriptor not despite the method under test is defined in the Descriptor interface they both implement.
The failing test case is based on the javadoc sentence "If the descriptor is empty, you will get an empty array.".
The test does:

Descriptor descr = new ImmutableDescriptor(new String[]{}, new Object[]{});
descr.getFieldValues(new String[]{"missing", "in", "action"}).

I put here the JCK test output :

(TEST) Retrieval with a non empty array on an empty Descriptor
(ERROR) Field values not as expected 
 GOT = [null, null, null]
 EXPECTED = []


###@###.### 2005-05-20 16:31:24 GMT

Comments
EVALUATION The specified behaviour is seriously counterintuitive and sure to generate bugs by the score. However, we can't change it for DescriptorSupport without the risk of breaking existing code. So either ImmutableDescriptor copies this horrible behaviour, or DescriptorSupport and ImmutableDescriptor are inconsistent and we add some weasel words to the Descriptor interface to allow this state of affairs. ###@###.### 2005-05-20 16:39:51 GMT We will change the spec so that it conforms to common sense. Since Model MBean descriptors are never empty (there are always required fields), this should not break any existing code. So the spec will say or imply that getFieldValues on an empty descriptor returns an array with as many null values as there are field names in the parameter. DescriptorSupport will be modified to follow this spec. ###@###.### 2005-06-22 10:53:39 GMT
20-05-2005