[picocontainer-scm] [jira] Created: (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 | <17849615.26714.1274367432399.JavaMail.haus-jira@codehaus01.managed.contegix.com> |
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
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>