spring-projects / spring-projects/spring-ldap

NameAwareAttribute.remove(Name) reports success without removing the value

Open
#1,676 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
375
Forks
501
Avg merge
6h 4m
Merged PRs (30d)
63

Description

NameAwareAttribute keeps a Name-keyed view of its values beside the values themselves, and the two go out of step.

add(Name) of a name already held under a different rendering replaces the stored string with the canonical rendering but leaves the view pointing at the old string. A later remove(Name) removes the view entry, fails to find the old string in values, and returns true with the value still held. clear() leaves the view populated, so a following add(Name) of the same name returns false and adds nothing. initValuesAsNames() maps an LdapName element to its toString(), so remove(Name) cannot remove the object actually held.

Through DirContextAdapter, with the directory rendering the DN with a space after the comma:

BasicAttributes attrs = new BasicAttributes();
BasicAttribute member = new BasicAttribute("member");
member.add("cn=John Doe, ou=People");
attrs.put(member);
DirContextAdapter adapter = new DirContextAdapter(attrs, LdapUtils.newLdapName("cn=group"));
adapter.setUpdateMode(true);
adapter.addAttributeValue("member", LdapUtils.newLdapName("cn=John Doe,ou=People"));
adapter.removeAttributeValue("member", LdapUtils.newLdapName("cn=John Doe,ou=People"));
// the member is still held; the modification items never remove it

remove(int) had the same class of problem in #437. Observed on main at e77c93f3.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating NameAwareAttribute and read add(Name), remove(Name), clear(), and initValuesAsNames(); then trace how DirContextAdapter exercises these methods. Reproduce the rendering-mismatch example and verify that remove(Name) removes the held value, clear() resets the name view, and LdapName elements can be removed successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.