ejb@glassfish.java.net

Re: null handling in SessionContext.lookup(null)

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Thu, 02 Mar 2006 15:10:07 -0500

Cheng Fang wrote:

>I happen to notice this in EJBContextImpl.java:
>
> public Object lookup(String name) {
> Object o = null;
> try {
> if( initialContext == null ) {
> initialContext = new InitialContext();
> }
> // name is relative to the private component namespace
> o = initialContext.lookup("java:comp/env/" + name);
> } catch(Exception e) {
> throw new IllegalArgumentException(e);
> }
> return o;
> }
>
>
>It is possible that there exists a resource at name "java:comp/env/null"
>and this is a valid resource name. Right now in glassfish
>SessionContext.lookup(null) will return such a resource, rather than an
>IllegalArgumentException.
>
Yup, good catch Cheng. If there's no java:comp/env/null entry, it will
correctly throw
IllegalArgumentException, but if there happens to be an entry at
java:comp/env/null, it wil
incorrectly treat lookup(null) as lookup("null"). Please file a bug
for this. Thanks.

 --ken

>
>Thanks.
>-- Cheng
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
>For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>
>