Skip to content

Setting cache time-to-live for the health endpoint has no effect #28882

Closed

Description

@maxxedev

In spring-boot 2.6.0 and 2.6.1, it appears that cache.time-to-live for actuator endpoints are broken.

Read operations are not cached even if configured to be so.

Example to reproduce:

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        System.setProperty("management.endpoint.health.cache.time-to-live", "10s");
        System.setProperty("management.endpoint.health.show-details", "ALWAYS");
        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    HealthIndicator dateTimeHealthIndator() {
        return () -> Health.up()
                           .withDetail("dateTime", OffsetDateTime.now())
                           .build();
    }
}


$ date ; curl -s localhost:8080/actuator/health | jq .components.dateTimeHealthIndator
Tue Nov 30 15:48:55 PST 2021
{
  "status": "UP",
  "details": {
    "dateTime": "2021-11-30T15:48:55.284381-08:00"
  }
}

$ date ; curl -s localhost:8080/actuator/health | jq .components.dateTimeHealthIndator
Tue Nov 30 15:48:59 PST 2021
{
  "status": "UP",
  "details": {
    "dateTime": "2021-11-30T15:48:59.120667-08:00"
  }
}

According to @wilkinsona , this is likely a regression introduced by changes in https://github.com/spring-projects/spring-boot/issues/25471

Activity

  1. wilkinsona commented on Dec 1, 2021

    @wilkinsona
    Member

    Thanks for raising this, @maxxedev. AFAIK, it's just the health endpoint that's affected.

  2. changed the title [-]cache time-to-live for actutator endpoints broken[/-] on Dec 1, 2021
  3. added
    type: regressionA regression from a previous release
    and removed
    status: waiting-for-triageAn issue that has not yet been triaged. Contributions will not be accepted.
    on Dec 1, 2021
  4. added this to the 2.6.x milestone on Dec 1, 2021
  5. self-assigned this
    on Dec 16, 2021
  6. added a commit that references this issue on Dec 18, 2021
    4cc8012
  7. modified the milestones: 2.6.x, 2.6.2 on Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions