Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
35b74185
Commit
35b74185
authored
Dec 20, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test ordering problems by always clearing URL stream handler factory
Closes gh-19349
parent
3cadde09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
TomcatServletWebServerFactoryTests.java
...b/embedded/tomcat/TomcatServletWebServerFactoryTests.java
+0
-5
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+11
-0
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java
View file @
35b74185
...
@@ -19,7 +19,6 @@ package org.springframework.boot.web.embedded.tomcat;
...
@@ -19,7 +19,6 @@ package org.springframework.boot.web.embedded.tomcat;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.time.Duration
;
import
java.time.Duration
;
...
@@ -54,7 +53,6 @@ import org.apache.catalina.core.StandardWrapper;
...
@@ -54,7 +53,6 @@ import org.apache.catalina.core.StandardWrapper;
import
org.apache.catalina.startup.Tomcat
;
import
org.apache.catalina.startup.Tomcat
;
import
org.apache.catalina.util.CharsetMapper
;
import
org.apache.catalina.util.CharsetMapper
;
import
org.apache.catalina.valves.RemoteIpValve
;
import
org.apache.catalina.valves.RemoteIpValve
;
import
org.apache.catalina.webresources.TomcatURLStreamHandlerFactory
;
import
org.apache.jasper.servlet.JspServlet
;
import
org.apache.jasper.servlet.JspServlet
;
import
org.apache.tomcat.JarScanFilter
;
import
org.apache.tomcat.JarScanFilter
;
import
org.apache.tomcat.JarScanType
;
import
org.apache.tomcat.JarScanType
;
...
@@ -75,7 +73,6 @@ import org.springframework.http.HttpHeaders;
...
@@ -75,7 +73,6 @@ import org.springframework.http.HttpHeaders;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
...
@@ -108,8 +105,6 @@ public class TomcatServletWebServerFactoryTests extends AbstractServletWebServer
...
@@ -108,8 +105,6 @@ public class TomcatServletWebServerFactoryTests extends AbstractServletWebServer
@After
@After
public
void
restoreTccl
()
{
public
void
restoreTccl
()
{
ReflectionTestUtils
.
setField
(
TomcatURLStreamHandlerFactory
.
class
,
"instance"
,
null
);
ReflectionTestUtils
.
setField
(
URL
.
class
,
"factory"
,
null
);
Thread
.
currentThread
().
setContextClassLoader
(
getClass
().
getClassLoader
());
Thread
.
currentThread
().
setContextClassLoader
(
getClass
().
getClassLoader
());
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
35b74185
...
@@ -67,6 +67,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -67,6 +67,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
org.apache.catalina.webresources.TomcatURLStreamHandlerFactory
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.entity.InputStreamFactory
;
import
org.apache.http.client.entity.InputStreamFactory
;
import
org.apache.http.client.protocol.HttpClientContext
;
import
org.apache.http.client.protocol.HttpClientContext
;
...
@@ -111,6 +112,7 @@ import org.springframework.http.client.ClientHttpRequest;
...
@@ -111,6 +112,7 @@ import org.springframework.http.client.ClientHttpRequest;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.StreamUtils
;
...
@@ -161,6 +163,15 @@ public abstract class AbstractServletWebServerFactoryTests {
...
@@ -161,6 +163,15 @@ public abstract class AbstractServletWebServerFactoryTests {
}
}
}
}
@After
public
void
clearUrlStreamHandlerFactory
()
{
if
(
ClassUtils
.
isPresent
(
"org.apache.catalina.webresources.TomcatURLStreamHandlerFactory"
,
getClass
().
getClassLoader
()))
{
ReflectionTestUtils
.
setField
(
TomcatURLStreamHandlerFactory
.
class
,
"instance"
,
null
);
ReflectionTestUtils
.
setField
(
URL
.
class
,
"factory"
,
null
);
}
}
@Test
@Test
public
void
startServlet
()
throws
Exception
{
public
void
startServlet
()
throws
Exception
{
AbstractServletWebServerFactory
factory
=
getFactory
();
AbstractServletWebServerFactory
factory
=
getFactory
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment