Broader attempt at fixing URLStreamHandlerFactory pollution problem

This is a follow-on from d341499 that takes a broader approach to
clearing URLs URLStreamHandlerFactory.

See gh-5290
This commit is contained in:
Andy Wilkinson 2016-06-15 16:46:17 +01:00
parent 6d06411cdc
commit 7e854d090f
2 changed files with 9 additions and 10 deletions

View File

@ -65,6 +65,8 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@ -86,6 +88,7 @@ import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.SocketUtils;
import org.springframework.util.StreamUtils;
@ -118,6 +121,12 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
private final HttpClientContext httpClientContext = HttpClientContext.create();
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@After
public void tearDown() {
if (this.container != null) {

View File

@ -17,7 +17,6 @@
package org.springframework.boot.context.embedded.jetty;
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -38,8 +37,6 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.thread.ThreadPool;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.InOrder;
@ -49,7 +46,6 @@ import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.http.HttpHeaders;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.anyObject;
@ -68,12 +64,6 @@ import static org.mockito.Mockito.mock;
public class JettyEmbeddedServletContainerFactoryTests
extends AbstractEmbeddedServletContainerFactoryTests {
@BeforeClass
@AfterClass
public static void uninstallUrlStreamHandlerFactory() {
ReflectionTestUtils.setField(URL.class, "factory", null);
}
@Override
protected JettyEmbeddedServletContainerFactory getFactory() {
return new JettyEmbeddedServletContainerFactory(0);