Bird
0
0

Given this custom health indicator code, what will the health endpoint show?

medium📝 component behavior Q4 of 15
Spring Boot - Actuator
Given this custom health indicator code, what will the health endpoint show?
public class DiskSpaceHealthIndicator implements HealthIndicator { public Health health() { long freeSpace = 500L; if (freeSpace > 1000) { return Health.up().build(); } else { return Health.down().withDetail("freeSpace", freeSpace).build(); } } }
A{"status":"DOWN","details":{"freeSpace":500}}
B{"status":"UP"}
C{"status":"DOWN"}
D{"status":"UP","details":{"freeSpace":500}}
Step-by-Step Solution
Solution:
  1. Step 1: Analyze freeSpace value and condition

    freeSpace is 500, which is less than 1000, so health is down with details.
  2. Step 2: Determine health endpoint output

    Health.down() with detail freeSpace=500 will produce JSON with status DOWN and details.
  3. Final Answer:

    {"status":"DOWN","details":{"freeSpace":500}} -> Option A
  4. Quick Check:

    Health status = DOWN with freeSpace detail [OK]
Quick Trick: If freeSpace < threshold, health is DOWN with details [OK]
Common Mistakes:
  • Assuming status UP because freeSpace is positive
  • Ignoring details in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes