diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-12-09 09:34:43 -0600 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-12-10 20:46:09 +0100 |
commit | d1fd889554bccbb50122550899dbb66b90b04f78 (patch) | |
tree | 9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-process | |
parent | f86a1094588e4e47b3abf612891af0431653cd0e (diff) | |
download | sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip |
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-process')
6 files changed, 19 insertions, 22 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java b/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java index c5b24a04d95..18a46ae849a 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java +++ b/server/sonar-process/src/main/java/org/sonar/process/logging/Log4JPropertiesBuilder.java @@ -150,7 +150,7 @@ public class Log4JPropertiesBuilder extends AbstractLogHelper { } private void applyLevelByProperty(Props props, String loggerKey, List<String> properties) { - putLevel(loggerKey, resolveLevel(props, properties.stream().toArray(String[]::new))); + putLevel(loggerKey, resolveLevel(props, properties.toArray(new String[0]))); } private void applyHardcodedLevel(String loggerName, Level newLevel) { diff --git a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java b/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java index e1810fd3ffa..0e6af6b5f77 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/logging/LogbackHelper.java @@ -124,8 +124,8 @@ public class LogbackHelper extends AbstractLogHelper { return rootContext; } - private void applyLevelByProperty(Props props, Logger logger, List<String> properties) { - logger.setLevel(resolveLevel(props, properties.stream().toArray(String[]::new))); + private static void applyLevelByProperty(Props props, Logger logger, List<String> properties) { + logger.setLevel(resolveLevel(props, properties.toArray(new String[0]))); } private static void applyHardcodedLevel(LoggerContext rootContext, String loggerName, Level newLevel) { diff --git a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java index 9de9e9ea187..42b52e0ad76 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ConfigurationUtilsTest.java @@ -19,17 +19,17 @@ */ package org.sonar.process; -import com.google.common.collect.Maps; +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.test.TestUtils; -import java.io.File; -import java.util.Map; -import java.util.Properties; - import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; @@ -44,7 +44,7 @@ public class ConfigurationUtilsTest { input.setProperty("hello", "world"); input.setProperty("url", "${env:SONAR_JDBC_URL}"); input.setProperty("do_not_change", "${SONAR_JDBC_URL}"); - Map<String, String> variables = Maps.newHashMap(); + Map<String, String> variables = new HashMap<>(); variables.put("SONAR_JDBC_URL", "jdbc:h2:mem"); Properties output = ConfigurationUtils.interpolateVariables(input, variables); @@ -74,7 +74,7 @@ public class ConfigurationUtilsTest { @Test public void loadPropsFromCommandLineArgs_load_properties_from_file() throws Exception { File propsFile = temp.newFile(); - FileUtils.write(propsFile, "foo=bar"); + FileUtils.write(propsFile, "foo=bar", StandardCharsets.UTF_8); Props result = ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()}); assertThat(result.value("foo")).isEqualTo("bar"); @@ -87,7 +87,7 @@ public class ConfigurationUtilsTest { FileUtils.deleteQuietly(propsFile); try { - ConfigurationUtils.loadPropsFromCommandLineArgs(new String[]{propsFile.getAbsolutePath()}); + ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()}); fail(); } catch (IllegalStateException e) { assertThat(e).hasMessage("Could not read properties from file: " + propsFile.getAbsolutePath()); diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java index 43b7dd06118..22f66eebe88 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java @@ -140,13 +140,10 @@ public class ProcessEntryPointTest { final ProcessEntryPoint entryPoint = new ProcessEntryPoint(props, exit, commands, runtime); final StandardProcess process = new StandardProcess(); - Thread runner = new Thread() { - @Override - public void run() { - // starts and waits until terminated - entryPoint.launch(process); - } - }; + Thread runner = new Thread(() -> { + // starts and waits until terminated + entryPoint.launch(process); + }); runner.start(); waitForOperational(process, commands); diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java index dd4b39b1de1..943950243f8 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessPropertiesTest.java @@ -115,7 +115,7 @@ public class ProcessPropertiesTest { processProperties.completeDefaults(p); } - private class FakeExtension1 implements CoreExtension { + private static class FakeExtension1 implements CoreExtension { @Override public String getName() { @@ -135,7 +135,7 @@ public class ProcessPropertiesTest { } } - private class FakeExtension2 implements CoreExtension { + private static class FakeExtension2 implements CoreExtension { @Override public String getName() { @@ -155,7 +155,7 @@ public class ProcessPropertiesTest { } } - private class FakeExtension3 implements CoreExtension { + private static class FakeExtension3 implements CoreExtension { @Override public String getName() { diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java index 8090920dc39..b94af6ec8f0 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/SharedHealthStateImplTest.java @@ -115,7 +115,7 @@ public class SharedHealthStateImplTest { when(hazelcastMember.getClusterTime()).thenReturn(clusterTime); assertThat(underTest.readAll()) - .containsOnly(expected.values().stream().toArray(NodeHealth[]::new)); + .containsOnly(expected.values().toArray(new NodeHealth[0])); assertThat(logging.getLogs()).isEmpty(); } |