|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.web.servlet.mvc.support;
|
18 | 18 |
|
19 | 19 | import java.lang.reflect.Method;
|
| 20 | +import java.net.SocketException; |
20 | 21 | import java.util.Arrays;
|
21 | 22 | import java.util.Collections;
|
22 | 23 |
|
|
42 | 43 | import org.springframework.web.bind.MissingPathVariableException;
|
43 | 44 | import org.springframework.web.bind.MissingServletRequestParameterException;
|
44 | 45 | import org.springframework.web.bind.ServletRequestBindingException;
|
| 46 | +import org.springframework.web.client.RestClientException; |
45 | 47 | import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
|
46 | 48 | import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
47 | 49 | import org.springframework.web.multipart.support.MissingServletRequestPartException;
|
|
60 | 62 | *
|
61 | 63 | * @author Arjen Poutsma
|
62 | 64 | * @author Sebastien Deleuze
|
| 65 | + * @author Yanming Zhou |
63 | 66 | */
|
64 | 67 | class DefaultHandlerExceptionResolverTests {
|
65 | 68 |
|
@@ -248,6 +251,20 @@ void handleMaxUploadSizeExceededException() {
|
248 | 251 | assertThat(response.getErrorMessage()).isEqualTo("Maximum upload size exceeded");
|
249 | 252 | }
|
250 | 253 |
|
| 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 | + |
| 261 | + @Test |
| 262 | + void handleRestClientExceptionHasConnectionResetMessage() { |
| 263 | + RestClientException ex = new RestClientException("I/O error", new SocketException("Connection reset")); |
| 264 | + ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex); |
| 265 | + assertThat(mav).as("ModelAndView is returned").isNull(); |
| 266 | + } |
| 267 | + |
251 | 268 | @Test
|
252 | 269 | void customModelAndView() {
|
253 | 270 | ModelAndView expected = new ModelAndView();
|
|
0 commit comments