Spring Framework Research & Evidence-Based Practice 5 — Questions and Answers
Question 1: Which Spring Boot Actuator metric exposed via Micrometer provides evidence of HTTP request duration distribution including slow outliers?
- http.server.requests with percentile histograms enabled (Correct answer)
- system.cpu.usage
- jvm.memory.used
- process.uptime
Correct answer: http.server.requests with percentile histograms enabled
The http.server.requests metric with percentile histograms enabled (management.metrics.distribution.percentiles-histogram) records request duration distribution, exposing tail latency outliers.
Question 2: A team uses Spring's @Profile annotation to control bean registration. What is the evidence-based way to verify the correct profile is active in an integration test?
- Read the application.properties file manually
- Use @ActiveProfiles in the test class and assert with Environment.getActiveProfiles() (Correct answer)
- Trust that the default profile is always active
- Check the server's OS environment variables at runtime
Correct answer: Use @ActiveProfiles in the test class and assert with Environment.getActiveProfiles()
@ActiveProfiles on the test class activates specific profiles, and asserting via Environment.getActiveProfiles() provides concrete evidence that the expected profile-conditional beans were loaded.
Question 3: Evidence-based capacity planning for a Spring Boot application on Kubernetes relies on which Actuator probe configuration?
- Exposing /actuator/health/liveness and /actuator/health/readiness as separate probes (Correct answer)
- Using a single /actuator/health probe for both liveness and readiness
- Disabling Actuator in production for security
- Using /actuator/metrics as the probe endpoint
Correct answer: Exposing /actuator/health/liveness and /actuator/health/readiness as separate probes
Spring Boot 2.3+ provides separate /actuator/health/liveness and /actuator/health/readiness probes, giving Kubernetes fine-grained evidence for restart vs. traffic-routing decisions.
Question 4: When researching Spring AOP proxy behavior, which empirical test reveals whether a self-invocation call bypasses the proxy?
- Call the advised method externally and check the advice fires; then call it internally (this.method()) and confirm the advice does NOT fire (Correct answer)
- Add logging inside the aspect and count lines
- Set spring.aop.proxy-target-class=true and redeploy
- Use @Aspect on the test class itself
Correct answer: Call the advised method externally and check the advice fires; then call it internally (this.method()) and confirm the advice does NOT fire
Externally calling the proxied method while observing advice execution, then repeating via self-invocation (this.method()), empirically demonstrates that proxy-based AOP does not intercept internal calls.
Question 5: Which Spring testing utility allows researchers to assert on the exact JSON structure and values returned by a REST controller without starting a full HTTP server?
- RestTemplate with a live server
- MockMvc with jsonPath assertions (Correct answer)
- Postman collection runner
- HttpURLConnection in a @BeforeEach
Correct answer: MockMvc with jsonPath assertions
MockMvc with Hamcrest jsonPath matchers performs full Spring MVC request/response cycle including serialization in-process, allowing precise JSON structure assertions without a running HTTP server.
Question 6: A Spring researcher wants to prove that BeanPostProcessors execute before @PostConstruct. Which approach provides direct experimental evidence?
- Read the Spring documentation without running any code
- Add logging in a custom BeanPostProcessor and in a @PostConstruct method; observe log order at startup (Correct answer)
- Check the bean definition XML order
- Use @DependsOn to force the sequence
Correct answer: Add logging in a custom BeanPostProcessor and in a @PostConstruct method; observe log order at startup
Instrumenting both a BeanPostProcessor.postProcessBeforeInitialization() and a @PostConstruct method with distinct log statements and observing startup log order is direct empirical evidence of the initialization sequence.
Question 7: When publishing Spring research results on dependency injection performance, which measurement methodology avoids the common confound of including Spring context startup time in per-injection latency?
- Measure total application startup and divide by bean count
- Warm up the context fully before the timed loop, then measure only the injection or lookup operation in steady state (Correct answer)
- Use @SpringBootTest for every individual measurement
- Report only the first cold-start measurement
Correct answer: Warm up the context fully before the timed loop, then measure only the injection or lookup operation in steady state
Fully warming the Spring context before the timed benchmark loop isolates the actual injection or lookup cost from one-time startup overhead, producing valid steady-state performance data.
Which Spring Boot Actuator metric exposed via Micrometer provides evidence of HTTP request duration distribution including slow outliers?