[picocontainer-scm] [jira] Resolved: (PICO-384) ClassCastException obtaining component from parent container when using CompositePicoContainer.

"Paul Hammant (JIRA)" <jira-yCVjj/[email protected]> Wed, 9 Nov 2011 22:00:52 -0600 (CST)
Newsgroups gmane.comp.java.picocontainer.cvs
Message-ID <1328907598.9900.1320897652178.JavaMail.j2ee-jira@codehaus01-new.managed.contegix.com>
     [ https://jira.codehaus.org/browse/PICO-384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Hammant resolved PICO-384.
-------------------------------

    Resolution: Fixed
      Assignee: Paul Hammant

> ClassCastException obtaining component from parent container when using CompositePicoContainer.
> -----------------------------------------------------------------------------------------------
>
>                 Key: PICO-384
>                 URL: https://jira.codehaus.org/browse/PICO-384
>             Project: PicoContainer
>          Issue Type: Bug
>          Components: PicoContainer (Java)
>    Affects Versions: 2.13.5
>            Reporter: Chris Simmons
>            Assignee: Paul Hammant
>         Attachments: TestPicoClassCast.java
>
>
> I encountered a ClassCastException when using a composite container.  I *think* I've tracked down the problem to this method:-
> org.picocontainer.DefaultPicoContainer.getInstance(ComponentAdapter<?>, Class)
> In this case isLocal is false and parent != null.  Its passing in the key from the component adapter rather than using the componentKey.  In this case these are different.  componentKey is Impl2 but the componentAdapter's key is AnInterface.  Subsequently the composite pico returns Impl1 and it attempts to cast it to anImpl2.
> I'd guess that changing it to do this would fix this problem but perhaps it would cause other problems?
> return getParent().getComponent(componentKey);

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
    <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>