HTTP 408 Request Timeout in JHipster Spring MVC: Intercepting Container‑Generated Timeouts
0 reputation · 29 Sept 2024, 12:15 UTC
Goal
To enable graceful handling of HTTP 408 Request Timeout responses in a JHipster‑generated Spring MVC application by ensuring that a global @ControllerAdvice can capture, log, or transform the error before the client receives it.
Constraints
JHipster relies solely on the servlet container’s server.connection-timeout setting; the container issues a 408 response before the request reaches any controller or advice. The generated code provides no cancellation token or per‑endpoint timeout configuration.
Unresolved Decisions
Whether to:
- Introduce a custom timeout annotation that the generator can enforce per endpoint.
- Implement a filter or interceptor that can translate container‑generated 408s into
ResponseStatusExceptionfor global handling. - Explore reactive alternatives (e.g., Spring WebFlux) that expose cancellation semantics.
Specific Questions
- Is there a mechanism to intercept a 408 Request Timeout before the servlet container closes the connection, allowing a
@ControllerAdviceto process it? - Can a per‑endpoint timeout annotation be added to JHipster controllers, and how would the generated code enforce it?
- What is the recommended pattern for propagating cancellation or timeout exceptions to global exception handlers in a Spring MVC context?