From 374b0be668439f51f7e07a1c155dcbf79d1a8d33 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 15 May 2019 14:30:09 -0500 Subject: [PATCH] SONAR-12002 Fail startup if JRE < 11 --- .../application/command/CeJvmOptions.java | 13 +-- .../command/CommandFactoryImpl.java | 8 +- .../application/command/EsJvmOptions.java | 19 +-- .../application/command/WebJvmOptions.java | 21 ++-- .../application/command/CeJvmOptionsTest.java | 21 +--- .../command/CommandFactoryImplTest.java | 9 +- .../application/command/EsJvmOptionsTest.java | 110 ++---------------- .../command/WebJvmOptionsTest.java | 22 +--- .../main/java/org/sonar/process/System2.java | 18 --- .../main/java/org/sonar/application/App.java | 5 +- .../scanner/bootstrap/GlobalContainer.java | 2 +- .../sonarqube/ws/client/HttpConnector.java | 1 - 12 files changed, 42 insertions(+), 207 deletions(-) diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/CeJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/CeJvmOptions.java index 44a58d1d52d..57e6e95b052 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/CeJvmOptions.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/CeJvmOptions.java @@ -25,20 +25,19 @@ import java.util.Map; public class CeJvmOptions extends JvmOptions { - public CeJvmOptions(File tmpDir, JavaVersion javaVersion) { - super(mandatoryOptions(tmpDir, javaVersion)); + public CeJvmOptions(File tmpDir) { + super(mandatoryOptions(tmpDir)); } - private static Map mandatoryOptions(File tmpDir, JavaVersion javaVersion) { + private static Map mandatoryOptions(File tmpDir) { Map res = new LinkedHashMap<>(3); res.put("-Djava.awt.headless=", "true"); res.put("-Dfile.encoding=", "UTF-8"); res.put("-Djava.io.tmpdir=", tmpDir.getAbsolutePath()); - if (javaVersion.isAtLeastJava11()) { - // avoid illegal reflective access operations done by MyBatis - res.put("--add-opens=java.base/java.util=ALL-UNNAMED", ""); - } + // avoid illegal reflective access operations done by MyBatis + res.put("--add-opens=java.base/java.util=ALL-UNNAMED", ""); + return res; } } diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java b/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java index 6e4a0aaea73..f254c255e20 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java @@ -72,13 +72,11 @@ public class CommandFactoryImpl implements CommandFactory { private final Props props; private final File tempDir; private final System2 system2; - private final JavaVersion javaVersion; - public CommandFactoryImpl(Props props, File tempDir, System2 system2, JavaVersion javaVersion) { + public CommandFactoryImpl(Props props, File tempDir, System2 system2) { this.props = props; this.tempDir = tempDir; this.system2 = system2; - this.javaVersion = javaVersion; String javaToolOptions = system2.getenv(ENV_VAR_JAVA_TOOL_OPTIONS); if (javaToolOptions != null && !javaToolOptions.trim().isEmpty()) { LoggerFactory.getLogger(CommandFactoryImpl.class) @@ -153,7 +151,7 @@ public class CommandFactoryImpl implements CommandFactory { public JavaCommand createWebCommand(boolean leader) { File homeDir = props.nonNullValueAsFile(PATH_HOME.getKey()); - WebJvmOptions jvmOptions = new WebJvmOptions(tempDir, javaVersion) + WebJvmOptions jvmOptions = new WebJvmOptions(tempDir) .addFromMandatoryProperty(props, WEB_JAVA_OPTS.getKey()) .addFromMandatoryProperty(props, WEB_JAVA_ADDITIONAL_OPTS.getKey()); addProxyJvmOptions(jvmOptions); @@ -180,7 +178,7 @@ public class CommandFactoryImpl implements CommandFactory { public JavaCommand createCeCommand() { File homeDir = props.nonNullValueAsFile(PATH_HOME.getKey()); - CeJvmOptions jvmOptions = new CeJvmOptions(tempDir, javaVersion) + CeJvmOptions jvmOptions = new CeJvmOptions(tempDir) .addFromMandatoryProperty(props, CE_JAVA_OPTS.getKey()) .addFromMandatoryProperty(props, CE_JAVA_ADDITIONAL_OPTS.getKey()); addProxyJvmOptions(jvmOptions); diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java index 05f87fe6077..7df9652ba12 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/EsJvmOptions.java @@ -27,7 +27,6 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; import org.sonar.process.Props; -import org.sonar.process.System2; public class EsJvmOptions extends JvmOptions { private static final String ELASTICSEARCH_JVM_OPTIONS_HEADER = "# This file has been automatically generated by SonarQube during startup.\n" + @@ -37,16 +36,12 @@ public class EsJvmOptions extends JvmOptions { "\n"; public EsJvmOptions(Props props, File tmpDir) { - this(System2.INSTANCE, props, tmpDir); - } - - EsJvmOptions(System2 system2, Props props, File tmpDir) { - super(mandatoryOptions(system2, props, tmpDir)); + super(mandatoryOptions(tmpDir, props)); } // this basically writes down the content of jvm.options file distributed in vanilla Elasticsearch package // with some changes to fit running bundled in SQ - private static Map mandatoryOptions(System2 system2, Props props, File tmpDir) { + private static Map mandatoryOptions(File tmpDir, Props props) { Map res = new LinkedHashMap<>(30); // GC configuration res.put("-XX:+UseConcMarkSweepGC", ""); @@ -115,16 +110,6 @@ public class EsJvmOptions extends JvmOptions { // res.put("8:-XX:GCLogFileSize", "64m"); // JDK 9+ GC logging // res.put("9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m", ""); - // due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise - // time/date parsing will break in an incompatible way for some date patterns and locals - if (system2.isJava9()) { - res.put("-Djava.locale.providers=", "COMPAT"); - } - - if (system2.isJava10()) { - // temporary workaround for C2 bug with JDK 10 on hardware with AVX-512 - res.put("-XX:UseAVX=", "2"); - } if (!props.value("sonar.jdbc.url", "").contains("jdbc:h2") && !props.valueAsBoolean("sonar.es.bootstrap.checks.disable")) { res.put("-Des.enforce.bootstrap.checks=", "true"); diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/WebJvmOptions.java b/server/sonar-main/src/main/java/org/sonar/application/command/WebJvmOptions.java index 8e55debe854..9b13df769de 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/WebJvmOptions.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/WebJvmOptions.java @@ -24,25 +24,24 @@ import java.util.LinkedHashMap; import java.util.Map; public class WebJvmOptions extends JvmOptions { - public WebJvmOptions(File tmpDir, JavaVersion javaVersion) { - super(mandatoryOptions(tmpDir, javaVersion)); + public WebJvmOptions(File tmpDir) { + super(mandatoryOptions(tmpDir)); } - private static Map mandatoryOptions(File tmpDir, JavaVersion javaVersion) { + private static Map mandatoryOptions(File tmpDir) { Map res = new LinkedHashMap<>(3); res.put("-Djava.awt.headless=", "true"); res.put("-Dfile.encoding=", "UTF-8"); res.put("-Djava.io.tmpdir=", tmpDir.getAbsolutePath()); - if (javaVersion.isAtLeastJava11()) { - // avoid illegal reflective access operations done by MyBatis - res.put("--add-opens=java.base/java.util=ALL-UNNAMED", ""); + // avoid illegal reflective access operations done by MyBatis + res.put("--add-opens=java.base/java.util=ALL-UNNAMED", ""); + + // avoid illegal reflective access operations done by Tomcat + res.put("--add-opens=java.base/java.lang=ALL-UNNAMED", ""); + res.put("--add-opens=java.base/java.io=ALL-UNNAMED", ""); + res.put("--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED", ""); - // avoid illegal reflective access operations done by Tomcat - res.put("--add-opens=java.base/java.lang=ALL-UNNAMED", ""); - res.put("--add-opens=java.base/java.io=ALL-UNNAMED", ""); - res.put("--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED", ""); - } return res; } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/CeJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/CeJvmOptionsTest.java index 3cb6f5a81f9..89ee9972281 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/CeJvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/CeJvmOptionsTest.java @@ -27,39 +27,22 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class CeJvmOptionsTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); private File tmpDir; - private JavaVersion javaVersion = mock(JavaVersion.class); private CeJvmOptions underTest; @Before public void setUp() throws IOException { tmpDir = temporaryFolder.newFolder(); - underTest = new CeJvmOptions(tmpDir, javaVersion); + underTest = new CeJvmOptions(tmpDir); } @Test - public void constructor_sets_mandatory_JVM_options_before_java11() throws IOException { - when(javaVersion.isAtLeastJava11()).thenReturn(false); - - @Test - public void constructor_sets_mandatory_JVM_options_before_java11() { - when(javaVersion.isAtLeastJava11()).thenReturn(false); - underTest = new CeJvmOptions(tmpDir, javaVersion); - assertThat(underTest.getAll()).containsExactly( - "-Djava.awt.headless=true", "-Dfile.encoding=UTF-8", "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath()); - } - - @Test - public void constructor_sets_mandatory_JVM_options_for_java11() throws IOException { - when(javaVersion.isAtLeastJava11()).thenReturn(true); - + public void constructor_sets_mandatory_JVM_options() { assertThat(underTest.getAll()).containsExactly( "-Djava.awt.headless=true", "-Dfile.encoding=UTF-8", "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath(), "--add-opens=java.base/java.util=ALL-UNNAMED"); diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java index babc1e2204b..ff20bebcd0b 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java @@ -53,7 +53,6 @@ public class CommandFactoryImplTest { public TemporaryFolder temp = new TemporaryFolder(); private System2 system2 = Mockito.mock(System2.class); - private JavaVersion javaVersion = Mockito.mock(JavaVersion.class); private File homeDir; private File tempDir; private File logsDir; @@ -77,7 +76,7 @@ public class CommandFactoryImplTest { public void constructor_logs_no_warning_if_env_variable_JAVA_TOOL_OPTIONS_is_not_set() { attachMemoryAppenderToLoggerOf(CommandFactoryImpl.class); - new CommandFactoryImpl(new Props(new Properties()), tempDir, system2, javaVersion); + new CommandFactoryImpl(new Props(new Properties()), tempDir, system2); assertThat(listAppender.getLogs()).isEmpty(); } @@ -87,7 +86,7 @@ public class CommandFactoryImplTest { when(system2.getenv("JAVA_TOOL_OPTIONS")).thenReturn("sds"); attachMemoryAppenderToLoggerOf(CommandFactoryImpl.class); - new CommandFactoryImpl(new Props(new Properties()), tempDir, system2, javaVersion); + new CommandFactoryImpl(new Props(new Properties()), tempDir, system2); assertThat(listAppender.getLogs()) .extracting(ILoggingEvent::getMessage) @@ -101,7 +100,7 @@ public class CommandFactoryImplTest { when(system2.getenv("ES_JAVA_OPTS")).thenReturn("xyz"); attachMemoryAppenderToLoggerOf(CommandFactoryImpl.class); - new CommandFactoryImpl(new Props(new Properties()), tempDir, system2, javaVersion); + new CommandFactoryImpl(new Props(new Properties()), tempDir, system2); assertThat(listAppender.getLogs()) .extracting(ILoggingEvent::getMessage) @@ -326,7 +325,7 @@ public class CommandFactoryImplTest { ServiceLoaderWrapper serviceLoaderWrapper = mock(ServiceLoaderWrapper.class); when(serviceLoaderWrapper.load()).thenReturn(ImmutableSet.of()); new ProcessProperties(serviceLoaderWrapper).completeDefaults(props); - return new CommandFactoryImpl(props, tempDir, system2, javaVersion); + return new CommandFactoryImpl(props, tempDir, system2); } private void attachMemoryAppenderToLoggerOf(Class loggerClass) { diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java index f1a9b08552f..83d310f0d05 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/EsJvmOptionsTest.java @@ -19,9 +19,7 @@ */ package org.sonar.application.command; -import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; import java.io.File; import java.io.IOException; import java.util.Properties; @@ -31,13 +29,10 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.sonar.process.Props; -import org.sonar.process.System2; import org.sonar.test.ExceptionCauseMatcher; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; @RunWith(DataProviderRunner.class) public class EsJvmOptionsTest { @@ -49,10 +44,9 @@ public class EsJvmOptionsTest { private Properties properties = new Properties(); @Test - @UseDataProvider("java8or11") - public void constructor_sets_mandatory_JVM_options_on_Java_8_and_11(System2 system2) throws IOException { + public void constructor_sets_mandatory_JVM_options_on_Java_11() throws IOException { File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir); + EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) .containsExactly( @@ -78,128 +72,44 @@ public class EsJvmOptionsTest { } @Test - @UseDataProvider("java8or11") - public void constructor_does_not_force_boostrap_checks_if_sonarqube_property_is_true(System2 system2) throws IOException { + public void constructor_does_not_force_boostrap_checks_if_sonarqube_property_is_true() throws IOException { properties.put("sonar.es.bootstrap.checks.disable", "true"); File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir); + EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) .doesNotContain("-Des.enforce.bootstrap.checks=true"); } @Test - @UseDataProvider("java8or11") - public void constructor_forces_boostrap_checks_if_jdbc_url_property_does_not_exist(System2 system2) throws IOException { + public void constructor_forces_boostrap_checks_if_jdbc_url_property_does_not_exist() throws IOException { File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir); + EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) .contains("-Des.enforce.bootstrap.checks=true"); } @Test - @UseDataProvider("java8or11") - public void constructor_forces_boostrap_checks_if_jdbc_url_property_is_not_h2(System2 system2) throws IOException { + public void constructor_forces_boostrap_checks_if_jdbc_url_property_is_not_h2() throws IOException { properties.put("sonar.jdbc.url", randomAlphanumeric(53)); File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir); + EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) .contains("-Des.enforce.bootstrap.checks=true"); } @Test - @UseDataProvider("java8or11") - public void constructor_does_not_force_boostrap_checks_if_jdbc_url_property_contains_h2(System2 system2) throws IOException { + public void constructor_does_not_force_boostrap_checks_if_jdbc_url_property_contains_h2() throws IOException { properties.put("sonar.jdbc.url", "jdbc:h2:tcp://ffoo:bar/sonar"); File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(system2, new Props(properties), tmpDir); + EsJvmOptions underTest = new EsJvmOptions(new Props(properties), tmpDir); assertThat(underTest.getAll()) .doesNotContain("-Des.enforce.bootstrap.checks=true"); } - @DataProvider - public static Object[][] java8or11() { - System2 java8 = mock(System2.class); - when(java8.isJava9()).thenReturn(false); - when(java8.isJava10()).thenReturn(false); - System2 java10 = mock(System2.class); - when(java10.isJava9()).thenReturn(false); - when(java10.isJava10()).thenReturn(false); - return new Object[][] { - {java8}, - {java10} - }; - } - - @Test - public void constructor_sets_mandatory_JVM_options_on_Java_9() throws IOException { - System2 java9 = mock(System2.class); - when(java9.isJava9()).thenReturn(true); - when(java9.isJava10()).thenReturn(false); - - File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(java9, new Props(properties), tmpDir); - - assertThat(underTest.getAll()) - .containsExactly( - "-XX:+UseConcMarkSweepGC", - "-XX:CMSInitiatingOccupancyFraction=75", - "-XX:+UseCMSInitiatingOccupancyOnly", - "-Des.networkaddress.cache.ttl=60", - "-Des.networkaddress.cache.negative.ttl=10", - "-XX:+AlwaysPreTouch", - "-Xss1m", - "-Djava.awt.headless=true", - "-Dfile.encoding=UTF-8", - "-Djna.nosys=true", - "-XX:-OmitStackTraceInFastThrow", - "-Dio.netty.noUnsafe=true", - "-Dio.netty.noKeySetOptimization=true", - "-Dio.netty.recycler.maxCapacityPerThread=0", - "-Dlog4j.shutdownHookEnabled=false", - "-Dlog4j2.disable.jmx=true", - "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath(), - "-XX:ErrorFile=../logs/es_hs_err_pid%p.log", - "-Djava.locale.providers=COMPAT", - "-Des.enforce.bootstrap.checks=true"); - } - - @Test - public void constructor_sets_mandatory_JVM_options_on_Java_10() throws IOException { - System2 java10 = mock(System2.class); - when(java10.isJava9()).thenReturn(false); - when(java10.isJava10()).thenReturn(true); - - File tmpDir = temporaryFolder.newFolder(); - EsJvmOptions underTest = new EsJvmOptions(java10, new Props(properties), tmpDir); - - assertThat(underTest.getAll()) - .containsExactly( - "-XX:+UseConcMarkSweepGC", - "-XX:CMSInitiatingOccupancyFraction=75", - "-XX:+UseCMSInitiatingOccupancyOnly", - "-Des.networkaddress.cache.ttl=60", - "-Des.networkaddress.cache.negative.ttl=10", - "-XX:+AlwaysPreTouch", - "-Xss1m", - "-Djava.awt.headless=true", - "-Dfile.encoding=UTF-8", - "-Djna.nosys=true", - "-XX:-OmitStackTraceInFastThrow", - "-Dio.netty.noUnsafe=true", - "-Dio.netty.noKeySetOptimization=true", - "-Dio.netty.recycler.maxCapacityPerThread=0", - "-Dlog4j.shutdownHookEnabled=false", - "-Dlog4j2.disable.jmx=true", - "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath(), - "-XX:ErrorFile=../logs/es_hs_err_pid%p.log", - "-XX:UseAVX=2", - "-Des.enforce.bootstrap.checks=true"); - } - /** * This test may fail if SQ's test are not executed with target Java version 8. */ diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java index 65def9d3519..2d647b6dc8d 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/WebJvmOptionsTest.java @@ -27,39 +27,22 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class WebJvmOptionsTest { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); private File tmpDir; - private JavaVersion javaVersion = mock(JavaVersion.class); private WebJvmOptions underTest; @Before public void setUp() throws IOException { tmpDir = temporaryFolder.newFolder(); - underTest = new WebJvmOptions(tmpDir, javaVersion); + underTest = new WebJvmOptions(tmpDir); } @Test - public void constructor_sets_mandatory_JVM_options_before_java11() throws IOException { - when(javaVersion.isAtLeastJava11()).thenReturn(false); - - @Test - public void constructor_sets_mandatory_JVM_options_before_java11() { - when(javaVersion.isAtLeastJava11()).thenReturn(false); - underTest = new WebJvmOptions(tmpDir, javaVersion); - assertThat(underTest.getAll()).containsExactly( - "-Djava.awt.headless=true", "-Dfile.encoding=UTF-8", "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath()); - } - - @Test - public void constructor_sets_mandatory_JVM_options_for_java11() throws IOException { - when(javaVersion.isAtLeastJava11()).thenReturn(true); - + public void constructor_sets_mandatory_JVM_options() { assertThat(underTest.getAll()).containsExactly( "-Djava.awt.headless=true", "-Dfile.encoding=UTF-8", "-Djava.io.tmpdir=" + tmpDir.getAbsolutePath(), "--add-opens=java.base/java.util=ALL-UNNAMED", @@ -67,5 +50,4 @@ public class WebJvmOptionsTest { "--add-opens=java.base/java.io=ALL-UNNAMED", "--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED"); } - } diff --git a/server/sonar-process/src/main/java/org/sonar/process/System2.java b/server/sonar-process/src/main/java/org/sonar/process/System2.java index e74ba7d4dea..93a46cc3dd0 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/System2.java +++ b/server/sonar-process/src/main/java/org/sonar/process/System2.java @@ -41,14 +41,6 @@ public interface System2 { public boolean isOsWindows() { return SystemUtils.IS_OS_WINDOWS; } - - public boolean isJava9() { - return SystemUtils.JAVA_VERSION != null && SystemUtils.JAVA_VERSION.startsWith("9"); - } - - public boolean isJava10() { - return SystemUtils.JAVA_VERSION != null && SystemUtils.JAVA_VERSION.startsWith("10"); - } }; /** @@ -65,14 +57,4 @@ public interface System2 { * True if this is MS Windows. */ boolean isOsWindows(); - - /** - * True is current Java version is Java 9. - */ - boolean isJava9(); - - /** - * True is current Java version is Java 10. - */ - boolean isJava10(); } diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 9133001ecda..f9e7fe288fc 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -20,7 +20,6 @@ package org.sonar.application; import java.io.IOException; -import org.slf4j.LoggerFactory; import org.sonar.api.SonarEdition; import org.sonar.api.internal.MetadataLoader; import org.sonar.application.command.CommandFactory; @@ -61,7 +60,7 @@ public class App { appState.registerClusterName(settings.getProps().nonNullValue(CLUSTER_NAME.getKey())); AppReloader appReloader = new AppReloaderImpl(settingsLoader, fileSystem, appState, logging); fileSystem.reset(); - CommandFactory commandFactory = new CommandFactoryImpl(settings.getProps(), fileSystem.getTempDir(), System2.INSTANCE, JavaVersion.INSTANCE); + CommandFactory commandFactory = new CommandFactoryImpl(settings.getProps(), fileSystem.getTempDir(), System2.INSTANCE); try (ProcessLauncher processLauncher = new ProcessLauncherImpl(fileSystem.getTempDir())) { Scheduler scheduler = new SchedulerImpl(settings, appReloader, commandFactory, processLauncher, appState); @@ -91,7 +90,7 @@ public class App { } if (!javaVersion.isAtLeastJava11()) { - LoggerFactory.getLogger(this.getClass()).warn("SonarQube will require Java 11+ starting on next version"); + throw new IllegalStateException("SonarQube requires Java 11+ to run"); } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java index e600bf3b3b7..0076875aa49 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java @@ -83,7 +83,7 @@ public class GlobalContainer extends ComponentContainer { try { String.class.getMethod("isBlank"); } catch (NoSuchMethodException e) { - LOG.warn("SonarQube scanners will require Java 11+ starting on next version"); + throw new IllegalStateException("SonarScanner requires Java 11+ to run"); } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java index 45533360e70..c568cc54abf 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java @@ -49,7 +49,6 @@ import static org.sonarqube.ws.WsUtils.nullToEmpty; /** * Connect to any SonarQube server available through HTTP or HTTPS. - *

TLS 1.0, 1.1 and 1.2 are supported on both Java 7 and 8. SSLv3 is not supported.

*

The JVM system proxies are used.

*/ public class HttpConnector implements WsConnector { -- 2.39.5