rwinch / spring-ldap

Apache License 2.0
0 stars 0 forks source link

LDAP-304: NullPointerException DirContextAdapter.collectModifications #79

Closed rwinch closed 8 years ago

rwinch commented 10 years ago

Original Reporter: thommy25 Environment: Not Specified Version: 2.0.1 Migrated From: https://jira.spring.io//browse/LDAP-304 My domain class has following javax.naming.Name attribute:

{code} @Attribute(name = "memberDN") private final Set memberDNs = new HashSet();

public Set<Name> getMemberDNs() {
    return this.memberDNs ;
}

public void addMemberDN(final Name memberDN) {
    this.memberDNs.add(memberDN);
}

public void removeMemberDN(final Name memberDN) {
    this.memberDNs.remove(memberDN);
}

{code}

1) First I created a new instance (without setting this attribut !!!) and save the instance by calling LDAPRepository.save() method.

2) After that I modified this attribut by calling addMemberDN(), and saving the instance again throws a NullPointerException

{noformat} [ERROR] java.lang.NullPointerException [ERROR] at org.springframework.ldap.core.DirContextAdapter.collectModifications(DirContextAdapter.java:338) {noformat}

look at the sourcecode:

{code} NameAwareAttribute currentAttribute = originalAttrs.get(changedAttr.getID());

    if(changedAttr.hasValuesAsNames()) {
        try {

338: currentAttribute.initValuesAsNames(); } {code}

problem: currentAttribute is null, because this attribute has not been seet,

rwinch commented 10 years ago

cdevos said: Hi,

We're currently using spring-ldap and it's been ok until we ran on this issue, do you plan on having it fixed anytime soon? We found a quick fix by mapping the DN not to a Name but to a String and handle the DN in java... but it's not flawless...

Cheers,

Clément

rwinch commented 10 years ago

rwinch said: Right now my focus is on getting Spring Security 4.0 M2 out.

Of course a PR with a proper fix and test would be most welcome & speed things up quite a bit.