Added a check for empty attribute. LDAP-215
This commit is contained in:
@@ -558,7 +558,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public Object getObjectAttribute(String name) {
|
||||
Attribute oneAttr = originalAttrs.get(name);
|
||||
if (oneAttr == null) {
|
||||
if (oneAttr == null || oneAttr.size() == 0) { // LDAP-215
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -83,6 +83,19 @@ public class DirContextAdapterTest extends TestCase {
|
||||
assertNull(s);
|
||||
}
|
||||
|
||||
public void testGetStringAttributeDoesExistButWithNoValue() throws Exception {
|
||||
final Attributes attrs = new BasicAttributes();
|
||||
attrs.put(new BasicAttribute("abc"));
|
||||
class TestableDirContextAdapter extends DirContextAdapter {
|
||||
public TestableDirContextAdapter() {
|
||||
super(attrs, null);
|
||||
}
|
||||
}
|
||||
tested = new TestableDirContextAdapter();
|
||||
String s = tested.getStringAttribute("abc");
|
||||
assertNull(s);
|
||||
}
|
||||
|
||||
public void testGetStringAttributeExists() throws Exception {
|
||||
final Attributes attrs = new BasicAttributes();
|
||||
attrs.put(new BasicAttribute("abc", "def"));
|
||||
|
||||
Reference in New Issue
Block a user