Skip to content

Fix/ldap health indicator unknown status - #51440

Closed
2heunxun wants to merge 285 commits into
spring-projects:4.1.xfrom
2heunxun:fix/ldap-health-indicator-unknown-status
Closed

2heunxun wants to merge 285 commits into
spring-projects:4.1.xfrom
2heunxun:fix/ldap-health-indicator-unknown-status

Conversation

@2heunxun

Copy link
Copy Markdown
Contributor

What happened?

LdapHealthIndicator.doHealthCheck() reads the LDAP server's protocol version from a JNDI environment attribute and only reports the health status as UP if that version is present:

String version = this.ldapOperations.executeReadOnly(versionContextExecutor);
if (version != null) {
    builder.up().withDetail("version", version);
}

However, executeReadOnly() returning without throwing already means the LDAP connection succeeded.

java.naming.ldap.version is a JNDI environment attribute that a client requests explicitly. It is not something the server always echoes back, and Spring LDAP's default LdapContextSource configuration does not set it.

As a result, in a common setup, version can be null even though the LDAP connection is perfectly healthy.

When this happens, builder.up() is never called. Since Health.Builder defaults to Status.UNKNOWN, the indicator incorrectly reports UNKNOWN for a working LDAP connection instead of UP.

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 return null, representing a successful connection where the LDAP version is unavailable, and asserts that:

  • The health status is UP.
  • No version detail is included.

On the current code, this test fails because the status is UNKNOWN instead of UP.

What does this PR change?

doHealthCheck() now calls builder.up() unconditionally after a successful executeReadOnly() call.

The version detail is only added when the version is available:

String version = this.ldapOperations.executeReadOnly(versionContextExecutor);
builder.up();

if (version != null) {
    builder.withDetail("version", version);
}

No public API changes are introduced.

Impact / risk

  • Connection succeeds + version available: Unchanged. Reports UP with the version detail.
  • Connection succeeds + version unavailable: Now correctly reports UP instead of UNKNOWN. This is the fix.
  • Connection fails: Unchanged. Reports DOWN through AbstractHealthIndicator's exception handling.

Tests

  • Added the regression test ldapIsUpWhenVersionIsUnavailable.
  • Existing LdapHealthIndicatorTests continue to pass.
  • checkstyleMain passes.
  • checkstyleTest passes.
  • format passes.
  • :module:spring-boot-ldap:test passes.

snicoll added 30 commits July 20, 2026 13:27
Spring Cloud Bindings still rely on the EnvironmentPostProcessor
interface that was deprecated in Spring Boot 4.0. This commit disables
this feature and adapts to new deprecation warnings.

See spring-projectsgh-50955
snicoll and others added 24 commits August 21, 2026 11:01
…nfiguration"

Allow `management.opentelemetry.otlp.compression` to act as a common
default for OTLP compression, mirroring the existing endpoint/headers
fallback. Tracing, logging and metrics exporters now fall back to it
when their own signal-specific compression property is unset.

See spring-projectsgh-50461
Closes spring-projectsgh-50461

* pr/50461:
  Polish "Align OTLP signal-specific properties with common fallback configuration"
  Align OTLP signal-specific properties with common fallback configuration
See spring-projectsgh-50595

Signed-off-by: Phil Clay <philsttr@users.noreply.github.com>
Derive logging.pattern.correlation from the configured MDC keys so that
log correlation keeps working when the keys are customized, instead of
silently rendering a blank correlation field.

Reject empty MDC keys and only clear Brave's default correlation fields
when the keys have been customized, so that applications using the
defaults are unaffected if Brave adds a default field.

Replace the tests that asserted on bean wiring with integration tests
covering the MDC contents, plus a smoke test for the log output.

See spring-projectsgh-50595
Closes spring-projectsgh-50595

* pr/50595:
  Polish "Allow configuring Micrometer Tracing MDC keys"
  Allow configuring Micrometer Tracing MDC keys
…lable

Previously, doHealthCheck() only called builder.up() when the LDAP
server's protocol version (java.naming.ldap.version) could be read
from the JNDI environment. That attribute is only populated when a
client explicitly requests it, and Spring LDAP's default
LdapContextSource does not set it, so it is commonly absent even on a
healthy connection.

As a result, a successful LDAP round trip with no version attribute
left the Health.Builder at its default Status.UNKNOWN instead of UP,
even though executeReadOnly() completed without error.

Call builder.up() unconditionally after a successful read, and only
guard the "version" detail on the attribute actually being present.

Signed-off-by: 2heunxun <seapeon@naver.com>
@2heunxun 2heunxun closed this Aug 25, 2026
@2heunxun

2heunxun commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorry for the noise, I originally opened this against the wrong base branch (4.1.x) and closed it (#51440).

@2heunxun
2heunxun deleted the fix/ldap-health-indicator-unknown-status branch August 25, 2026 12:32
@2heunxun
2heunxun restored the fix/ldap-health-indicator-unknown-status branch August 25, 2026 12:37
@philwebb philwebb added the status: declined A suggestion or change that we don't feel we should currently apply label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.