Details
-
Type: Improvement
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.2
-
Fix Version/s: 1.2
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
If I have the following ctor:
ComponentA(ComponentB[] bees)
The order of the ComponentB elements of the bees array is random-ish.
I think it would be desirable for ComponentA to get the array of ComponentB in order of registration.
I believe the culprit lies in CollectionComponentParameter's getMatchingComponentAdapters, which uses an HashMap, thus losing order of insertion. An easy of going around this would be to use jdk1.4's LinkedHashMap (just tested that, test passes), but that would of course break the 1.3 compat rule, so I guess that's a no go.
See attached testcase. (I added this to CollectionComponentParameterTestCase)
As you can see in the test, getting the components of type ComponentB (Strings here) gets them in the right order, it's only failing when injecting the array in ComponentA (Truc)
Issue Links
- is depended upon by
-
BERKANO-17 ApplicationProvider should be able to return a default app
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | test-order.txt [ 16100 ] |
Fix Version/s | 1.3 [ 11331 ] | |
Fix Version/s | 1.2 [ 11330 ] |
Link |
This issue is depended upon by |
Attachment | PICO-243-order.patch [ 17762 ] |
Assignee | Grégory Joseph [ gjoseph ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Resolved [ 5 ] |
Fix Version/s | 1.3 [ 11331 ] | |
Fix Version/s | 1.2 [ 11330 ] |
Well, there was never a guarantee of any order. See, if you register in a child pico a component with the same key as in its parent, you will never get the parent's component, although it might have been instantiated and is of a matching type. OTOH I would have been used a LinkedHashMap also ...