Skip to content

Rework LdapClient to Align with JdbcClient API#1446

Merged
jzheaux merged 2 commits intospring-projects:mainfrom
therepanic:gh-1404
Apr 9, 2026
Merged

Rework LdapClient to Align with JdbcClient API#1446
jzheaux merged 2 commits intospring-projects:mainfrom
therepanic:gh-1404

Conversation

@therepanic
Copy link
Copy Markdown
Contributor

@therepanic therepanic commented Mar 16, 2026

This commit added the single, optional, list, and stream methods to the LdapClient#SearchSpec and deprecated the implementations that will be deprecated by this change.

Please note that this is a WIP: I have a couple of comments that would be helpful to address.

Closes: gh-1404

Closes: spring-projectsgh-1404

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
Copy link
Copy Markdown
Collaborator

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far, @therepanic! If you feel good about it, let's go ahead and proceed with testing and with updating the documentation.

Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
Comment thread core/src/main/java/org/springframework/ldap/core/LdapClient.java
@therepanic
Copy link
Copy Markdown
Contributor Author

Are there any other concerns other than the duplication?

I believe we can't simply hide the same logic in toMap, toObject, and toStream methods as in DefaultLdapClient, since it relies on some local variables. For example, toList in DefaultLdapClient internally uses computeWithReadOnlyContext, which in turn uses contextSource, and so on.

What default implementation would we like to see for these methods?

@jzheaux
Copy link
Copy Markdown
Collaborator

jzheaux commented Mar 23, 2026

I see, @therepanic. Have you considered creating DefaultMappedSearchSpec inside of DefaultLdapClient?

@jzheaux
Copy link
Copy Markdown
Collaborator

jzheaux commented Mar 30, 2026

Hi, @therepanic, does my last comment help you find a direction to take the PR? I can also push a commit that you can work into the PR as you see fit, in case that helps.

Issue spring-projectsgh-1404

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
@jzheaux jzheaux marked this pull request as ready for review April 7, 2026 23:54
@jzheaux
Copy link
Copy Markdown
Collaborator

jzheaux commented Apr 8, 2026

@therepanic, I went ahead and pushed a suggestion along with updates to documentation and tests. I propose that we throw an UnsupportedOperationException in map since, without the state of the SearchSpec implementation, map cannot successfully return a new builder object.

Do you have any concerns with this approach? I'm confident enough in it that I'll merge it later this week if I don't hear from you, so don't feel obligated to respond. 👍

@jzheaux jzheaux changed the title [WIP] Add support for mandatory single result in LdapClient search operations Rework LdapClient to Align with JdbcClient API Apr 8, 2026
@therepanic
Copy link
Copy Markdown
Contributor Author

therepanic commented Apr 8, 2026

Hi, @jzheaux. I'm really sorry, I had some issues that kept me from figuring this out. I took a look at your changes in polish commit and I think this is exactly what's needed. You've also updated the documentation and tests, so I think it looks ready for merge.

After the merge and version update, we'll be able to update the implementation directly in all projects that use this API. Specifically, I've decided to monitor this issue within Spring Security itself, which is where the idea for these changes came from.

@jzheaux
Copy link
Copy Markdown
Collaborator

jzheaux commented Apr 9, 2026

@therepanic, it's not a problem at all. I found some time this week and that increased the changes of this going into 4.1, so it's a win-win.

@jzheaux jzheaux merged commit dfe9080 into spring-projects:main Apr 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for mandatory single result in LdapClient search operations

2 participants