diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-01-05 15:14:52 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-01-06 14:06:36 +0100 |
commit | 381a4374fbf51443a5c88308775852696755520f (patch) | |
tree | c6430cca2837c88beb72ca57f70a10919592ac6d /server | |
parent | 0d65396ad8c080f9811eb53796d670d30af89ff7 (diff) | |
download | sonarqube-381a4374fbf51443a5c88308775852696755520f.tar.gz sonarqube-381a4374fbf51443a5c88308775852696755520f.zip |
SONAR-8545 Upgrade Apache Tomcat from 8.0 to 8.5
Diffstat (limited to 'server')
4 files changed, 26 insertions, 66 deletions
diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index e420e95efee..fe686bff205 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -48,10 +48,6 @@ <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-logging-juli</artifactId> - </dependency> - <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> </dependency> diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java index 2111ccaa2aa..1ce5611e932 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java @@ -42,7 +42,6 @@ class TomcatConnectors { static void configure(Tomcat tomcat, Props props) { Connector httpConnector = newHttpConnector(props); - tomcat.setConnector(httpConnector); tomcat.getService().addConnector(httpConnector); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java index b15d76e0854..a12cc406cf1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java @@ -19,9 +19,6 @@ */ package org.sonar.server.app; -import static java.lang.String.format; -import static org.apache.commons.lang.StringUtils.isEmpty; - import com.google.common.annotations.VisibleForTesting; import java.io.File; import java.io.IOException; @@ -36,6 +33,9 @@ import org.sonar.api.utils.log.Loggers; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; +import static java.lang.String.format; +import static org.apache.commons.lang.StringUtils.isEmpty; + /** * Configures Tomcat contexts: * <ul> @@ -98,7 +98,6 @@ public class TomcatContexts { try { StandardContext context = (StandardContext) tomcat.addWebapp(contextPath, dir.getAbsolutePath()); context.setClearReferencesHttpClientKeepAliveThread(false); - context.setClearReferencesStatic(false); context.setClearReferencesStopThreads(false); context.setClearReferencesStopTimerThreads(false); context.setClearReferencesStopTimerThreads(false); diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/TomcatConnectorsTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/TomcatConnectorsTest.java index 0ab6b24c9bf..057ac23e02a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/app/TomcatConnectorsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/app/TomcatConnectorsTest.java @@ -38,9 +38,8 @@ import static org.mockito.Mockito.verify; public class TomcatConnectorsTest { - Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS); - - // ---- connectors + private static final int DEFAULT_PORT = 9000; + private Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS); @Test public void configure_thread_pool() { @@ -52,53 +51,27 @@ public class TomcatConnectorsTest { TomcatConnectors.configure(tomcat, props); - verify(tomcat).setConnector(argThat(new PropertiesMatcher( - ImmutableMap.<String, Object>of("minSpareThreads", 2, "maxThreads", 30, "acceptCount", 20)))); + verifyHttpConnector(DEFAULT_PORT, ImmutableMap.of("minSpareThreads", 2, "maxThreads", 30, "acceptCount", 20)); } @Test - public void configure_default_thread_pool() { + public void configure_defaults() { Props props = new Props(new Properties()); TomcatConnectors.configure(tomcat, props); - verify(tomcat).setConnector(argThat(new PropertiesMatcher( - ImmutableMap.<String, Object>of("minSpareThreads", 5, "maxThreads", 50, "acceptCount", 25)))); + verifyHttpConnector(DEFAULT_PORT, ImmutableMap.of("minSpareThreads", 5, "maxThreads", 50, "acceptCount", 25)); } @Test public void different_thread_pools_for_connectors() { Properties p = new Properties(); - p.setProperty("sonar.web.port", "9000"); p.setProperty("sonar.web.http.minThreads", "2"); Props props = new Props(p); TomcatConnectors.configure(tomcat, props); - verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() { - @Override - public boolean matches(Object o) { - Connector c = (Connector) o; - return c.getPort() == 9000 && c.getProperty("minSpareThreads").equals(2); - } - })); - } - - @Test - public void http_connector_is_enabled() { - Properties p = new Properties(); - p.setProperty("sonar.web.port", "9000"); - Props props = new Props(p); - - TomcatConnectors.configure(tomcat, props); - - verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() { - @Override - public boolean matches(Object o) { - Connector c = (Connector) o; - return c.getScheme().equals("http") && c.getPort() == 9000 && c.getProtocol().equals(TomcatConnectors.HTTP_PROTOCOL); - } - })); + verifyHttpConnector(DEFAULT_PORT, ImmutableMap.of("minSpareThreads", 2)); } @Test @@ -149,11 +122,9 @@ public class TomcatConnectorsTest { @Test public void test_max_http_header_size_for_http_connection() { - Properties properties = new Properties(); + TomcatConnectors.configure(tomcat, new Props(new Properties())); - Props props = new Props(properties); - TomcatConnectors.configure(tomcat, props); - verifyConnectorProperty(tomcat, "http", "maxHttpHeaderSize", TomcatConnectors.MAX_HTTP_HEADER_SIZE_BYTES); + verifyHttpConnector(DEFAULT_PORT, ImmutableMap.of("maxHttpHeaderSize", TomcatConnectors.MAX_HTTP_HEADER_SIZE_BYTES)); } @Test @@ -171,32 +142,27 @@ public class TomcatConnectorsTest { })); } - private static void verifyConnectorProperty(Tomcat tomcat, final String connectorScheme, - final String property, final Object propertyValue) { + private void verifyHttpConnector(int expectedPort, Map<String,Object> expectedProps) { verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() { @Override public boolean matches(Object o) { Connector c = (Connector) o; - return c.getScheme().equals(connectorScheme) && c.getProperty(property).equals(propertyValue); - } - })); - } - - private static class PropertiesMatcher extends ArgumentMatcher<Connector> { - private final Map<String, Object> expected; - - PropertiesMatcher(Map<String, Object> expected) { - this.expected = expected; - } - - public boolean matches(Object o) { - Connector c = (Connector) o; - for (Map.Entry<String, Object> entry : expected.entrySet()) { - if (!entry.getValue().equals(c.getProperty(entry.getKey()))) { + if (!c.getScheme().equals("http")) { + return false; + } + if (!c.getProtocol().equals(TomcatConnectors.HTTP_PROTOCOL)) { return false; } + if (c.getPort() != expectedPort) { + return false; + } + for (Map.Entry<String, Object> expectedProp : expectedProps.entrySet()) { + if (!expectedProp.getValue().equals(c.getProperty(expectedProp.getKey()))) { + return false; + } + } + return true; } - return true; - } + })); } } |