Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0-beta-5
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
this works:
MutablePicoContainer parent = new DefaultPicoContainer();
parent.registerComponentImplementation(Touchable.class, SimpleTouchable.class);
MutablePicoContainer child = new DefaultPicoContainer(parent);
child.registerComponentImplementation(DependsOnTouchable.class, DependsOnTouchable.class, new Parameter[]
assertNotNull(child.getComponentInstance(DependsOnTouchable.class));
this does not work:
MutablePicoContainer grandParent = new DefaultPicoContainer();
grandParent.registerComponentImplementation(Touchable.class, SimpleTouchable.class);
MutablePicoContainer parent = new DefaultPicoContainer(grandParent);
MutablePicoContainer child = new DefaultPicoContainer(parent);
child.registerComponentImplementation(DependsOnTouchable.class, DependsOnTouchable.class, new Parameter[] { new ComponentParameter((Object)Touchable.class) }
);
assertNotNull(child.getComponentInstance(DependsOnTouchable.class));
---------------------------------------------------------------------
a testcase and two fixes are provided:
1) a straightforward one, that calls parent.getComponentAdapter() recursively, if componentKeyToAdapterCache.get yields null
2) a conservative one, that creates correct map of keys -> component adapters from entire container hierarchy. It's rather baroque and performance ineffective IMO, but maybe it was implemented this way for a reason?
All testcases pass with either of these fixes.
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | conatinerHierarchyTestcase.diff [ 11461 ] |
Attachment | conatinerHierarchyStraightforwardFix.diff [ 11462 ] |
Attachment | conatinerHierarchyConservativeFix.diff [ 11463 ] |
Assignee | Aslak Hellesoy [ rinkrank ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Fix Version/s | 1.0-beta-5 [ 10145 ] |
the failing testcase