|
18 | 18 |
|
19 | 19 | import java.util.Collections;
|
20 | 20 | import java.util.Date;
|
21 |
| -import java.util.HashSet; |
22 | 21 | import java.util.List;
|
23 | 22 | import java.util.Map;
|
24 |
| -import java.util.Set; |
25 | 23 |
|
26 | 24 | import org.apache.commons.logging.Log;
|
27 | 25 | import reactor.core.publisher.Mono;
|
|
33 | 31 | import org.springframework.boot.web.reactive.error.ErrorAttributes;
|
34 | 32 | import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
|
35 | 33 | import org.springframework.context.ApplicationContext;
|
36 |
| -import org.springframework.core.NestedExceptionUtils; |
37 | 34 | import org.springframework.core.io.Resource;
|
38 | 35 | import org.springframework.core.log.LogMessage;
|
39 | 36 | import org.springframework.http.HttpLogging;
|
|
49 | 46 | import org.springframework.web.reactive.function.server.ServerResponse;
|
50 | 47 | import org.springframework.web.reactive.result.view.ViewResolver;
|
51 | 48 | import org.springframework.web.server.ServerWebExchange;
|
| 49 | +import org.springframework.web.util.DisconnectedClientHelper; |
52 | 50 | import org.springframework.web.util.HtmlUtils;
|
53 | 51 |
|
54 | 52 | /**
|
|
61 | 59 | */
|
62 | 60 | public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExceptionHandler, InitializingBean {
|
63 | 61 |
|
64 |
| - /** |
65 |
| - * Currently duplicated from Spring Web's DisconnectedClientHelper. |
66 |
| - */ |
67 |
| - private static final Set<String> DISCONNECTED_CLIENT_EXCEPTIONS; |
68 |
| - |
69 |
| - static { |
70 |
| - Set<String> exceptions = new HashSet<>(); |
71 |
| - exceptions.add("ClientAbortException"); |
72 |
| - exceptions.add("EOFException"); |
73 |
| - exceptions.add("EofException"); |
74 |
| - DISCONNECTED_CLIENT_EXCEPTIONS = Collections.unmodifiableSet(exceptions); |
75 |
| - } |
76 |
| - |
77 | 62 | private static final Log logger = HttpLogging.forLogName(AbstractErrorWebExceptionHandler.class);
|
78 | 63 |
|
79 | 64 | private final ApplicationContext applicationContext;
|
@@ -305,13 +290,7 @@ public Mono<Void> handle(ServerWebExchange exchange, Throwable throwable) {
|
305 | 290 | }
|
306 | 291 |
|
307 | 292 | private boolean isDisconnectedClientError(Throwable ex) {
|
308 |
| - return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName()) |
309 |
| - || isDisconnectedClientErrorMessage(NestedExceptionUtils.getMostSpecificCause(ex).getMessage()); |
310 |
| - } |
311 |
| - |
312 |
| - private boolean isDisconnectedClientErrorMessage(String message) { |
313 |
| - message = (message != null) ? message.toLowerCase() : ""; |
314 |
| - return (message.contains("broken pipe") || message.contains("connection reset by peer")); |
| 293 | + return DisconnectedClientHelper.isClientDisconnectedException(ex); |
315 | 294 | }
|
316 | 295 |
|
317 | 296 | /**
|
|
0 commit comments