spring-projects / spring-projects/spring-ldap
`LdapTemplate` constructor accepts a `null` `ContextSource`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 375
- Forks
- 501
- Avg merge
- 6h 4m
- Merged PRs (30d)
- 63
Description
Problem
The LadpTemplates constructor accepts null as a parameter.
https://github.com/spring-projects/spring-ldap/blob/1c75ae7d56d3a3cf8c58632d6ad5ecf578787954/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L116-L122
The LdapTemlate#afterPropertySet overwrite check for the instance type of the context. null expected to be represented as NullContextSource. This will fail after a new LadpTemplate(null) invocation because null is not an instance of NullContextSource.
https://github.com/spring-projects/spring-ldap/blob/1c75ae7d56d3a3cf8c58632d6ad5ecf578787954/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L1130-L1136
At the same time LdapTemplate#setContextSource check for nullness before setting by invoking Assert.notNull.
https://github.com/spring-projects/spring-ldap/blob/1c75ae7d56d3a3cf8c58632d6ad5ecf578787954/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L124-L131
Expectation
Aligned semantics across the class regarding the nullness of contextSource.
So new LadpTemplate(null) should either:
- throw an exception
- instanciate
LadpTemplate.contextSourcean instance ofNullContextSource
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in core/src/main/java/org/springframework/ldap/core/LdapTemplate.java at the constructor, setContextSource, and afterPropertiesSet methods. Compare how each handles a null ContextSource, then add regression coverage showing that new LdapTemplate(null) follows the chosen consistent behavior: rejecting null or using NullContextSource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100