LDAP-304: Check for modify null attribute
This commit is contained in:
@@ -333,7 +333,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
private void collectModifications(NameAwareAttribute changedAttr,
|
||||
List<ModificationItem> modificationList) throws NamingException {
|
||||
NameAwareAttribute currentAttribute = originalAttrs.get(changedAttr.getID());
|
||||
if(changedAttr.hasValuesAsNames()) {
|
||||
if(currentAttribute != null && changedAttr.hasValuesAsNames()) {
|
||||
try {
|
||||
currentAttribute.initValuesAsNames();
|
||||
} catch(IllegalArgumentException e) {
|
||||
|
||||
@@ -571,6 +571,18 @@ public class DirContextAdapterTest {
|
||||
assertEquals("123", (String) attr.get());
|
||||
}
|
||||
|
||||
// LDAP-304
|
||||
@Test
|
||||
public void testModifyNull() throws Exception {
|
||||
tested.setAttributeValue("memberDN", null);
|
||||
tested.setUpdateMode(true);
|
||||
assertTrue(tested.isUpdateMode());
|
||||
tested.setAttributeValue("memberDN", new LdapName("ou=test"));
|
||||
|
||||
ModificationItem[] mods = tested.getModificationItems();
|
||||
assertEquals(1, mods.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDn() throws Exception {
|
||||
DirContextAdapter tested = new DirContextAdapter(DUMMY_NAME);
|
||||
|
||||
Reference in New Issue
Block a user