[picocontainer-scm] [jira] Resolved: (PICO-370) JNDIProvided unsafe handling of JNDIObjectReference.get may cause NPE

"Paul Hammant (JIRA)" <jira-yCVjj/[email protected]> Wed, 2 Feb 2011 20:13:22 -0600 (CST)
Newsgroups gmane.comp.java.picocontainer.cvs
Message-ID <29364640.1411.1296699202318.JavaMail.haus-jira@codehaus01.managed.contegix.com>
     [ http://jira.codehaus.org/browse/PICO-370?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Hammant resolved PICO-370.
-------------------------------

       Resolution: Fixed
    Fix Version/s: 2.11.1
         Assignee: Paul Hammant

> JNDIProvided unsafe handling of JNDIObjectReference.get may cause NPE
> ---------------------------------------------------------------------
>
>                 Key: PICO-370
>                 URL: http://jira.codehaus.org/browse/PICO-370
>             Project: PicoContainer
>          Issue Type: Bug
>          Components: PicoContainer Gems
>    Affects Versions: 2.10
>            Reporter: Mathieu Rozieres
>            Assignee: Paul Hammant
>            Priority: Minor
>             Fix For: 2.11.1
>
>         Attachments: JNDIProvided.patch, JNDIProvided.patch
>
>
> JNDIObjectReference.get return a null value if the JNDI lookup failed with a NameNotFoundException. (JNDIObjectReference.java:51-62 in my 2.10.2 sources jar ).
> There are two possible NPE regarding this behaviour in JNDIProvided class. Here are the code snipped : 
> {code}
> public JNDIProvided(final JNDIObjectReference<T> reference) {
> 	this(reference.get().getClass(),reference);
> }
> {code}
> {code}
> // JNDIObjectReference<T> jndiReference;
> public Class<? extends T> getComponentImplementation() {
> 	return (Class<? extends T>) jndiReference.get().getClass();
> }
> {code}
> A solution can be to write the following method inside JNDIObjectReference and to call it instead of getting the class of the context.lookup result (moreover it may saves some JNDI lookup too)
> {code}
> public Class<?> returnedClass {
>       ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperClass();
>      return (Class) parameterizedtype.getActualTypeArguments()[0];
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
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>