-
Notifications
You must be signed in to change notification settings - Fork 38.5k
AsyncRequestNotUsableException thrown and logged after upgrade from Spring Boot 3.2.3 to Spring Boot 3.2.4 #32509
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
Comments
The change in behavior is due to #32340. We'll transfer this to Spring Framework so that they can investigate further. |
What's actually logging the exception? Previously, this would have been |
Hi looks like this is traced in a custom exception handler annotated with @ControllerAdvice. What is the recommendation here? I could simply ignore this specific exception, but what would be the performance impact of exceptions being generated/thrown on every request? Best regards |
In this case the exception only wraps the The exception implies the response is no longer usable, and you can't send any more data. You can treat it in the same way that you would the underlying I'm closing as there is nothing for us to do, but feel free to comment if necessary. |
How did you solve it?I am facing the same problem. Thanks. |
We are also seeing this error after an upgrade, it doesn't seem to happen for every request, just those that have used |
We didn't . The only solution I see is to suppress the exception in the custom exception handler. |
From what I see what has changed is the exception type thrown. Before spring-web:6.1.5 a ClientAbortException was thrown. Since 6.1.5 a AsyncRequestNotUsableException. So adding AsyncRequestNotUsableException to the exception handler will restore the old state. |
We faced a similar issue. From this thread, I am taking away that we would either have to handle the |
@namannigam never tried it. Sounds reasonable for APIs that are not async by nature. But I'm not the expert here. |
@namannigam yes. The main change is that |
@rstoyanchev I got the same issue after upgrading Spring for a higher version than If this is a wrapper only and a change from |
It's difficult to say without more details. The exception can occur in a wide range of scenarios, writing to the response. Also, check the cause, if it is a different exception perhaps. Tomcat may raise one of several |
I encountered issue with 3.2.6, there is some mitigation for that? |
@SiwyDym saw some mitigations using a controller advice ignoring it. just leave the method empty and it won't log anything
|
We do have handling for I've created #33225 to add default handling in |
Okay, thank You. I have a slightly different situation because I got these exceptions when using SSE so I also need to suppress |
@SiwyDym could you elaborate on your scenario a little more? You shouldn't have to handle exceptions in SSE, and there isn't much you can do for handling. I'm also unsure how IllegalStateException relates to this. Perhaps a small code snippet that shows example handling. |
I try to make some demo repository, but without success. The setup is like ///config scheduler
@Bean
public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setThreadNamePrefix("XXX-");
threadPoolTaskScheduler.setErrorHandler(t -> {
//FIXME: remove it after SB fix it, probably this issue: https://github.com/spring-projects/spring-framework/issues/33225
if (t instanceof IllegalStateException
&& (t.getMessage().equals("A non-container (application) thread attempted to use the AsyncContext after an " +
"error had occurred and the call to AsyncListener.onError() had returned. This is not allowed to avoid race conditions.")
|| t.getMessage().equals("The request associated with the AsyncContext has already completed processing."))
) {
log.debug("Please ignore below error, because it's inner issue in SB,", t);
}
});
return threadPoolTaskScheduler;
}
///// controller
@GetMapping(value = "/xxx/summary", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<List<XXXSummary>> xxxSummaryFlux() {
return fluxSink.asFlux().map(e -> xxxManager.getxxxSummary());
}
@ControllerAdvice
@Slf4j
static class CustomAdvice {
@ExceptionHandler(AsyncRequestNotUsableException.class)
void handleAsyncRequestNotUsableException(AsyncRequestNotUsableException e) {
//FIXME: remove it after SB fix it, probably this issue: https://github.com/spring-projects/spring-framework/issues/33225
log.debug("Please ignore below error, because it's inner issue in SB,", e);
}
}
///flux config
@Configuration
public class FluxConfig {
@Bean
Sinks.Many<Object> fluxSink() {
return Sinks.many().multicast().directBestEffort();
}
@Bean
FluxNotifier fluxNotifier(Sinks.Many<Object> fluxSink) { //used to trigger change
return new FluxNotifier(fluxSink);
}
} It sometimes entered this new |
Thanks for the extra context @SiwyDym. The change in #33225 is now in, and you should be able to remove your own |
Is this fix available with a spring boot release? |
@berkaygiris see #33225. This will be released with Framework 6.2 and Spring Boot 3.4. |
Uh oh!
There was an error while loading. Please reload this page.
Hi
after upgrading to spring boot 3.2.4 from 3.2.3 our applications start logging this exception over and over (I suspect on every request):
this did not happen with the 3.2.3 version and after a rollback the exceptions are no longer logged.
The exceptions themselves do not seem to have any functional impact.
Used JVM: Amazon Corretto JDK 21.0.2
Best regards
Vasil
The text was updated successfully, but these errors were encountered: