directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] Closed: (DIRSERVER-468) DirContext.search() with null Name results in NPE
Date Wed, 06 May 2009 17:09:30 GMT

     [ https://issues.apache.org/jira/browse/DIRSERVER-468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Lecharny closed DIRSERVER-468.
---------------------------------------


> DirContext.search() with null Name results in NPE
> -------------------------------------------------
>
>                 Key: DIRSERVER-468
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-468
>             Project: Directory ApacheDS
>          Issue Type: Improvement
>            Reporter: Enrique Rodriguez
>            Assignee: Alex Karasulu
>            Priority: Minor
>
> This is a minor issue I am marking as an improvement since the JNDI API doesn't appear
to say explicitly what the behavior is, so I'm entering this issue to document it.  The issue
is that if you supply a null Name as the name to search in DirContext.search() you get a NPE.
 If you supply a null String, however, it is treated as the empty String, which indicates
a search at the current context's name.  IMO, a null Name should be treated like the empty
String.
> So, a null Name fails with NPE:
>         Name name = null;
>         NamingEnumeration answer = ctx.search( name, matchAttrs, attrIDs );
> java.lang.NullPointerException
> 	at org.apache.ldap.common.name.LdapName.addAll(LdapName.java:527)
> 	at org.apache.ldap.server.jndi.ServerContext.buildTarget(ServerContext.java:843)
> 	at org.apache.ldap.server.jndi.ServerDirContext.search(ServerDirContext.java:488)
> ...
> But, a null String will work fine:
>         String name = null;
>         NamingEnumeration answer = ctx.search( name, matchAttrs, attrIDs );
> Which is the same as the empty String, which works fine, too;
>         String name = "";
>         NamingEnumeration answer = ctx.search( name, matchAttrs, attrIDs );

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message