-
Notifications
You must be signed in to change notification settings - Fork 38.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default async request timeout handling does not work with Jetty 9.x [SPR-14669] #19233
Comments
Rossen Stoyanchev commented I've looked at the log but It's hard to infer from the given amount of detail what may be going on. Is this reproducible in a small example application? We have project templates that may help. |
Izek Greenfield commented attached project that reproduce the problem. send request: POST: http://localhost:1357/dummy?sleep=9000 |
Rossen Stoyanchev commented Thanks for the sample. Something strange is going on and I suspect a Jetty issue but not 100% sure yet. The default behavior in Spring MVC, based on the Simply upgrading Jetty to the latest 9.3 changes the behavior. There is no longer an ERROR dispatch and the client does get the 503 but there is a different exception in the logs and I'm not sure what it's about since the response from a client perspective is the one I would expect to see:
I will experiment a little more to see if I can reproduce this with just Servlet API and Jetty. |
Rossen Stoyanchev commented BTW I used the following Filter to "see" the dispatches: @Bean
public FilterRegistrationBean myFilter() {
Filter filter = new Filter() {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
logger.info("\n\n" + ((HttpServletRequest) request).getMethod() + " " +
((HttpServletRequest) request).getRequestURI() +
", DispatcherType: " + request.getDispatcherType() + "\n\n");
filterChain.doFilter(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {}
public void destroy() {}
};
FilterRegistrationBean bean = new FilterRegistrationBean(filter);
bean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.ERROR,
DispatcherType.FORWARD, DispatcherType.INCLUDE);
return bean;
} |
Rossen Stoyanchev commented I've been able to reproduce the same behavior with a plain Servlet project running on Jetty (source here). In Jetty 9.3 a call to I will experiment with a fix in the |
Rossen Stoyanchev commented Meanwhile as a workaround you can add the following config: @Configuration
public static class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(5000);
configurer.registerDeferredResultInterceptors(
new DeferredResultProcessingInterceptorAdapter() {
@Override
public <T> boolean handleTimeout(NativeWebRequest req, DeferredResult<T> result) {
return result.setErrorResult(new AsyncTimeoutException());
}
});
}
} Where the AsyncTimeoutException is: @ResponseStatus(HttpStatus.SERVICE_UNAVAILABLE)
public static class AsyncTimeoutException extends Exception {
} |
Izek Greenfield commented thanks for that!! How I configure that with XML? thanks |
Rossen Stoyanchev commented There is an |
Rossen Stoyanchev commented This should now be fixed in the latest snapshots of all 3 fix versions. I've tested with your sample project and also another sample app but if you get a chance to confirm that would be great, thanks! |
Izek Greenfield opened SPR-14669 and commented
when I use async spring-mvc I send request with body:
PUT http://localhost/kuku?key=EKUpdateTestUpdate
Body: { "1": 1 }
if the request timed out then the error I get is:
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing:
log file attached!
Affects: 4.3.2
Attachments:
Issue Links:
Backported to: 4.2.8
2 votes, 2 watchers
The text was updated successfully, but these errors were encountered: