Skip to content

Commit b53b8ec

Browse files
committed
DisconnectedClientHelper should only be used for logging
See spring-projects#34264 (comment) Signed-off-by: Yanming Zhou <[email protected]>
1 parent eab730d commit b53b8ec

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,7 +51,6 @@
5151
import org.springframework.web.servlet.NoHandlerFoundException;
5252
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
5353
import org.springframework.web.servlet.resource.NoResourceFoundException;
54-
import org.springframework.web.util.DisconnectedClientHelper;
5554
import org.springframework.web.util.WebUtils;
5655

5756
/**
@@ -149,6 +148,7 @@
149148
* @author Arjen Poutsma
150149
* @author Rossen Stoyanchev
151150
* @author Juergen Hoeller
151+
* @author Yanming Zhou
152152
* @since 3.0
153153
* @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
154154
*/
@@ -246,9 +246,6 @@ else if (ex instanceof AsyncRequestNotUsableException) {
246246
return handleAsyncRequestNotUsableException(
247247
(AsyncRequestNotUsableException) ex, request, response, handler);
248248
}
249-
else if (DisconnectedClientHelper.isClientDisconnectedException(ex)) {
250-
return handleDisconnectedClientException(ex, request, response, handler);
251-
}
252249
}
253250
catch (Exception handlerEx) {
254251
if (logger.isWarnEnabled()) {
@@ -505,26 +502,6 @@ protected ModelAndView handleAsyncRequestNotUsableException(AsyncRequestNotUsabl
505502
return new ModelAndView();
506503
}
507504

508-
/**
509-
* Handle an Exception that indicates the client has gone away. This is
510-
* typically an {@link IOException} of a specific subtype or with a message
511-
* specific to the underlying Servlet container. Those are detected through
512-
* {@link DisconnectedClientHelper#isClientDisconnectedException(Throwable)}
513-
* <p>By default, do nothing since the response is not usable.
514-
* @param ex the {@code Exception} to be handled
515-
* @param request current HTTP request
516-
* @param response current HTTP response
517-
* @param handler the executed handler, or {@code null} if none chosen
518-
* at the time of the exception (for example, if multipart resolution failed)
519-
* @return an empty ModelAndView indicating the exception was handled
520-
* @since 6.2
521-
*/
522-
protected ModelAndView handleDisconnectedClientException(
523-
Exception ex, HttpServletRequest request, HttpServletResponse response, @Nullable Object handler) {
524-
525-
return new ModelAndView();
526-
}
527-
528505
/**
529506
* Handle an {@link ErrorResponse} exception.
530507
* <p>The default implementation sets status and the headers of the response

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java

-7
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,6 @@ void handleMaxUploadSizeExceededException() {
251251
assertThat(response.getErrorMessage()).isEqualTo("Maximum upload size exceeded");
252252
}
253253

254-
@Test
255-
void handleClientDisconnectedException() {
256-
SocketException ex = new SocketException("Connection reset");
257-
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
258-
assertThat(mav).as("No ModelAndView returned").isNotNull();
259-
}
260-
261254
@Test
262255
void handleRestClientExceptionHasConnectionResetMessage() {
263256
RestClientException ex = new RestClientException("I/O error", new SocketException("Connection reset"));

0 commit comments

Comments
 (0)