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

"Mathieu Rozieres (JIRA)" <jira-yCVjj/[email protected]>
Newsgroups gmane.comp.java.picocontainer.cvs
Message-ID <27774953.27642.1274451012411.JavaMail.haus-jira@codehaus01.managed.contegix.com>
     [ http://jira.codehaus.org/browse/PICO-370?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mathieu Rozieres updated PICO-370:
----------------------------------

    Attachment: JNDIProvided.patch

This patch modify JNDIProvided ctor interfaces, i.e an instance of the generic type is added.

> 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
>            Priority: Minor
>         Attachments: 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>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.