Skip to content
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

Support all "connection reset" exception phrases in DisconnectedClientHelper #33064

Closed
KazzmanK opened this issue Jun 18, 2024 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@KazzmanK
Copy link

In recent versions org.springframework.web.util.DisconnectedClientHelper was added. But we are facing some other sort of exceptions. Here is a sample stack trace

Unhandled exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message; nested exception is org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Connection reset
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:555)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
.......................................
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message; nested exception is org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Connection reset
	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:197)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:160)
	at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:133)
	at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)
............................................
Caused by: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Connection reset
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:315)
	at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:590)
............................................
Caused by: java.net.SocketException: Connection reset
	at java.base/sun.nio.ch.SocketChannelImpl.throwConnectionReset(SocketChannelImpl.java:394)
	at java.base/sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:426)

This kind of disconnect is not covered by Helper.
So, is it an oversight, or there is a distinct difference between handled EXCEPTION_PHRASES = .... "connection reset by peer" and not handled Connection reset ?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 18, 2024
@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jun 18, 2024
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 18, 2024
@sbrannen sbrannen added this to the 6.1.10 milestone Jun 18, 2024
@sbrannen sbrannen self-assigned this Jun 18, 2024
@sbrannen sbrannen changed the title DisconnectedClientHelper exceptions list is not enough? Support all "connection reset" exception phrases in DisconnectedClientHelper Jun 18, 2024
@sbrannen
Copy link
Member

Hi @KazzmanK,

Congratulations on submitting your first issue for the Spring Framework! 👍

So, is it an oversight, or there is a distinct difference between handled EXCEPTION_PHRASES = .... "connection reset by peer" and not handled Connection reset?

I believe we simply were not aware of that particular Connection reset exception message when that code was written.

Thus, in commit 203fa75 I've made this more lenient to match any exception message containing connection reset (ignoring case).

This will be available in 6.1.10, but you can also try it out in a 6.1.10 snapshot.

Cheers,

Sam

@KazzmanK
Copy link
Author

Hi! Thank you!

I believe we simply were not aware of that particular Connection reset exception message when that code was written.

We are here were wondering, is there a real difference in such exceptions, say one initiated by client or network failure, other by server failure.

@sbrannen
Copy link
Member

sbrannen commented Jun 19, 2024

Hi! Thank you!

You're welcome.

We were wondering, is there a real difference in such exceptions, say one initiated by client or network failure, other by server failure.

DisconnectedClientHelper makes a best-effort attempt at determining if the most specific exception (original exception) in the exception chain indicates that the "client has gone away".

For your particular use case, Tomcat throws a ClientAbortException which indicates "an abort of a request by a remote client" with a SocketException as the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants