Skip to content

Commit 0e6932d

Browse files
committed
Merge branch '2.1.x' into 2.2.x
Closes gh-19419
2 parents 8ed0b1a + 35b7418 commit 0e6932d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.File;
2020
import java.io.IOException;
2121
import java.net.URISyntaxException;
22-
import java.net.URL;
2322
import java.nio.charset.Charset;
2423
import java.nio.charset.StandardCharsets;
2524
import java.time.Duration;
@@ -54,7 +53,6 @@
5453
import org.apache.catalina.startup.Tomcat;
5554
import org.apache.catalina.util.CharsetMapper;
5655
import org.apache.catalina.valves.RemoteIpValve;
57-
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
5856
import org.apache.coyote.ProtocolHandler;
5957
import org.apache.coyote.http11.AbstractHttp11Protocol;
6058
import org.apache.jasper.servlet.JspServlet;
@@ -76,7 +74,6 @@
7674
import org.springframework.http.HttpStatus;
7775
import org.springframework.http.MediaType;
7876
import org.springframework.http.ResponseEntity;
79-
import org.springframework.test.util.ReflectionTestUtils;
8077
import org.springframework.util.FileSystemUtils;
8178
import org.springframework.util.LinkedMultiValueMap;
8279
import org.springframework.util.MultiValueMap;
@@ -106,8 +103,6 @@ protected TomcatServletWebServerFactory getFactory() {
106103

107104
@AfterEach
108105
void restoreTccl() {
109-
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", null);
110-
ReflectionTestUtils.setField(URL.class, "factory", null);
111106
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
112107
}
113108

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import javax.servlet.http.HttpServletResponse;
6868
import javax.servlet.http.HttpSession;
6969

70+
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
7071
import org.apache.http.client.HttpClient;
7172
import org.apache.http.client.entity.InputStreamFactory;
7273
import org.apache.http.client.protocol.HttpClientContext;
@@ -112,6 +113,7 @@
112113
import org.springframework.http.client.ClientHttpResponse;
113114
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
114115
import org.springframework.test.util.ReflectionTestUtils;
116+
import org.springframework.util.ClassUtils;
115117
import org.springframework.util.FileCopyUtils;
116118
import org.springframework.util.SocketUtils;
117119
import org.springframework.util.StreamUtils;
@@ -159,6 +161,15 @@ void tearDown() {
159161
}
160162
}
161163

164+
@AfterEach
165+
void clearUrlStreamHandlerFactory() {
166+
if (ClassUtils.isPresent("org.apache.catalina.webresources.TomcatURLStreamHandlerFactory",
167+
getClass().getClassLoader())) {
168+
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", null);
169+
ReflectionTestUtils.setField(URL.class, "factory", null);
170+
}
171+
}
172+
162173
@Test
163174
void startServlet() throws Exception {
164175
AbstractServletWebServerFactory factory = getFactory();

0 commit comments

Comments
 (0)