aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-24 12:36:43 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-24 12:39:46 +0200
commit680f549abb87cc79b0d09a07add1a666dd2d0387 (patch)
tree28b9285d1e7af895d09d153000f9c0519fd69a9f /sonar-application/src/main
parent9a6ec4bb5b2fd7b2e3e722246f460e99c4d1a564 (diff)
downloadsonarqube-680f549abb87cc79b0d09a07add1a666dd2d0387.tar.gz
sonarqube-680f549abb87cc79b0d09a07add1a666dd2d0387.zip
SONAR-4741 Log clear message when HTTP and HTTPS ports are the same
Diffstat (limited to 'sonar-application/src/main')
-rw-r--r--sonar-application/src/main/java/org/sonar/application/Connectors.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/Connectors.java b/sonar-application/src/main/java/org/sonar/application/Connectors.java
index 0a4bcd8c3c9..617b7d6a428 100644
--- a/sonar-application/src/main/java/org/sonar/application/Connectors.java
+++ b/sonar-application/src/main/java/org/sonar/application/Connectors.java
@@ -24,10 +24,7 @@ import org.apache.catalina.startup.Tomcat;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
class Connectors {
@@ -44,9 +41,7 @@ class Connectors {
connectors.addAll(Arrays.asList(newHttpConnector(props), newHttpsConnector(props)));
connectors.removeAll(Collections.singleton(null));
- if (connectors.isEmpty()) {
- throw new IllegalStateException("HTTP connectors are disabled");
- }
+ verify(connectors);
tomcat.setConnector(connectors.get(0));
for (Connector connector : connectors) {
@@ -54,6 +49,20 @@ class Connectors {
}
}
+ private static void verify(List<Connector> connectors) {
+ if (connectors.isEmpty()) {
+ throw new IllegalStateException("HTTP connectors are disabled");
+ }
+ Set<Integer> ports = new HashSet<Integer>();
+ for (Connector connector : connectors) {
+ int port = connector.getPort();
+ if (ports.contains(port)) {
+ throw new IllegalStateException(String.format("HTTP and HTTPS must not use the same port %d", port));
+ }
+ ports.add(port);
+ }
+ }
+
private static void configureShutdown(Tomcat tomcat, Props props) {
String shutdownToken = props.of("sonar.web.shutdown.token");
Integer shutdownPort = props.intOf("sonar.web.shutdown.port");