Repository navigation
LdapHealthIndicator reports UNKNOWN instead of UP when LDAP server doesn't expose a protocol version - #51441
Merged
philwebb merged 2 commits intoAug 25, 2026
Conversation
Member
|
This is a regression in 4.1 due to the changes in d26b689. |
Fix regression caused by commit d26b689 which caused `doHealthCheck()` to only call `builder.up()` when the LDAP server's protocol version (`java.naming.ldap.version`) could be read from the JNDI environment. See spring-projectsgh-51441 Signed-off-by: 2heunxun <seapeon@naver.com>
philwebb
force-pushed
the
fix/ldap-health-indicator-unknown-status
branch
from
August 25, 2026 18:47
f3062af to
014bbcc
Compare
Member
|
Thanks very much @2heunxun |
Contributor
Author
|
@philwebb My pleasure! Thanks for merging it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened?
LdapHealthIndicator.doHealthCheck()reads the LDAP server's protocol version from a JNDI environment attribute and only reports the health status asUPif that version is present:However,
executeReadOnly()returning without throwing already means the LDAP connection succeeded.java.naming.ldap.versionis a JNDI environment attribute that a client requests explicitly. It is not something the server always echoes back, and Spring LDAP's defaultLdapContextSourceconfiguration does not set it.As a result, in a common setup,
versioncan benulleven though the LDAP connection is perfectly healthy.When this happens,
builder.up()is never called. SinceHealth.Builderdefaults toStatus.UNKNOWN, the indicator incorrectly reportsUNKNOWNfor a working LDAP connection instead ofUP.What should happen?
A successful LDAP round trip should report
UP, regardless of whether the optional version detail is available.How to reproduce?
Added
LdapHealthIndicatorTests#ldapIsUpWhenVersionIsUnavailable.The test stubs
executeReadOnly()to returnnull, representing a successful connection where the LDAP version is unavailable, and asserts that:UP.versiondetail is included.On the current code, this test fails because the status is
UNKNOWNinstead ofUP.What does this PR change?
doHealthCheck()now callsbuilder.up()unconditionally after a successfulexecuteReadOnly()call.The
versiondetail is only added when the version is available:No public API changes are introduced.
Impact / risk
UPwith theversiondetail.UPinstead ofUNKNOWN. This is the fix.DOWNthroughAbstractHealthIndicator's exception handling.Tests
ldapIsUpWhenVersionIsUnavailable.LdapHealthIndicatorTestscontinue to pass.checkstyleMainpasses.checkstyleTestpasses.formatpasses.:module:spring-boot-ldap:testpasses.ps. Sorry for the noise. I originally opened this against the wrong base branch (4.1.x) and closed it (#51440). This PR targets main as intended.