United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6273765 ImmutableDescriptor.getFieldValues(non-empty-array) on an empty descriptor returns unexpected array
JDK-6273765 : ImmutableDescriptor.getFieldValues(non-empty-array) on an empty descriptor returns unexpected array

Details
Type:
Bug
Submit Date:
2005-05-20
Status:
Closed
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2005-12-21
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

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
                                     
2005-05-20



Hardware and Software, Engineered to Work Together