diff options
Diffstat (limited to 'server/sonar-process')
-rw-r--r-- | server/sonar-process/pom.xml | 32 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java (renamed from server/sonar-process/src/main/java/org/sonar/process/FileUtils.java) | 4 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java | 16 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java | 2 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java | 55 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java | 52 | ||||
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java (renamed from server/sonar-process/src/test/java/org/sonar/process/FileUtilsTest.java) | 30 | ||||
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java | 65 | ||||
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java | 33 | ||||
-rw-r--r-- | server/sonar-process/test-jar-with-dependencies.xml | 19 |
10 files changed, 84 insertions, 224 deletions
diff --git a/server/sonar-process/pom.xml b/server/sonar-process/pom.xml index 020a3b3c717..d1b29121f91 100644 --- a/server/sonar-process/pom.xml +++ b/server/sonar-process/pom.xml @@ -86,36 +86,4 @@ <scope>test</scope> </dependency> </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>test-jar-with-dependencies.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> </project> diff --git a/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java b/server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java index 3f2d9da8245..fc77e9b74d9 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/FileUtils.java +++ b/server/sonar-process/src/main/java/org/sonar/process/FileUtils2.java @@ -37,11 +37,11 @@ import static java.util.Objects.requireNonNull; * This utility class provides Java NIO based replacement for some methods of * {@link org.apache.commons.io.FileUtils Common IO FileUtils} class. */ -public final class FileUtils { +public final class FileUtils2 { private static final String DIRECTORY_CAN_NOT_BE_NULL = "Directory can not be null"; private static final EnumSet<FileVisitOption> FOLLOW_LINKS = EnumSet.of(FileVisitOption.FOLLOW_LINKS); - private FileUtils() { + private FileUtils2() { // prevents instantiation } diff --git a/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java b/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java index 25ca71f59fc..9d7060c680f 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java +++ b/server/sonar-process/src/main/java/org/sonar/process/Lifecycle.java @@ -23,11 +23,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; -import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,13 +47,8 @@ public class Lifecycle { private static final Map<State, Set<State>> TRANSITIONS = buildTransitions(); - private final List<LifecycleListener> listeners; private State state = INIT; - public Lifecycle(LifecycleListener... listeners) { - this.listeners = Arrays.stream(listeners).filter(Objects::nonNull).collect(Collectors.toList()); - } - private static Map<State, Set<State>> buildTransitions() { Map<State, Set<State>> res = new EnumMap<>(State.class); res.put(INIT, toSet(STARTING)); @@ -90,7 +82,6 @@ public class Lifecycle { if (TRANSITIONS.get(currentState).contains(to)) { this.state = to; res = true; - listeners.forEach(listener -> listener.successfulTransition(currentState, to)); } LOG.trace("tryToMoveTo from {} to {} => {}", currentState, to, res); return res; @@ -112,11 +103,4 @@ public class Lifecycle { public int hashCode() { return state.hashCode(); } - - public interface LifecycleListener { - /** - * Called when a transition from state {@code from} to state {@code to} was successful. - */ - void successfulTransition(State from, State to); - } } diff --git a/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java b/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java index 54978819f03..f17e1aa3438 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java +++ b/server/sonar-process/src/main/java/org/sonar/process/MinimumViableSystem.java @@ -25,7 +25,7 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; import static java.lang.String.format; -import static org.sonar.process.FileUtils.deleteQuietly; +import static org.sonar.process.FileUtils2.deleteQuietly; public class MinimumViableSystem { diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java index 28d7f0c4007..8af47f571ed 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java @@ -33,6 +33,12 @@ public class ProcessProperties { public static final String CLUSTER_SEARCH_DISABLED = "sonar.cluster.search.disabled"; public static final String CLUSTER_SEARCH_HOSTS = "sonar.cluster.search.hosts"; public static final String CLUSTER_WEB_DISABLED = "sonar.cluster.web.disabled"; + public static final String CLUSTER_MEMBERS = "sonar.cluster.members"; + public static final String CLUSTER_PORT = "sonar.cluster.port"; + public static final String CLUSTER_INTERFACES = "sonar.cluster.interfaces"; + public static final String CLUSTER_NAME = "sonar.cluster.name"; + public static final String HAZELCAST_LOG_LEVEL = "sonar.log.level.app.hazelcast"; + public static final String CLUSTER_WEB_LEADER = "sonar.cluster.web.startupLeader"; public static final String JDBC_URL = "sonar.jdbc.url"; public static final String JDBC_DRIVER_PATH = "sonar.jdbc.driverPath"; @@ -42,6 +48,7 @@ public class ProcessProperties { public static final String JDBC_MAX_WAIT = "sonar.jdbc.maxWait"; public static final String JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS = "sonar.jdbc.minEvictableIdleTimeMillis"; public static final String JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS = "sonar.jdbc.timeBetweenEvictionRunsMillis"; + public static final String JDBC_EMBEDDED_PORT = "sonar.embeddedDatabase.port"; public static final String PATH_DATA = "sonar.path.data"; public static final String PATH_HOME = "sonar.path.home"; @@ -104,29 +111,45 @@ public class ProcessProperties { public static Properties defaults() { Properties defaults = new Properties(); - defaults.put(ProcessProperties.SEARCH_CLUSTER_NAME, "sonarqube"); - defaults.put(ProcessProperties.SEARCH_HOST, "127.0.0.1"); - defaults.put(ProcessProperties.SEARCH_JAVA_OPTS, "-Xmx1G -Xms256m -Xss256k -Djna.nosys=true " + + defaults.put(SEARCH_CLUSTER_NAME, "sonarqube"); + defaults.put(SEARCH_HOST, "127.0.0.1"); + defaults.put(SEARCH_JAVA_OPTS, "-Xmx1G -Xms256m -Xss256k -Djna.nosys=true " + "-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly " + "-XX:+HeapDumpOnOutOfMemoryError"); - defaults.put(ProcessProperties.SEARCH_JAVA_ADDITIONAL_OPTS, ""); - - defaults.put(ProcessProperties.WEB_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"); - defaults.put(ProcessProperties.WEB_JAVA_ADDITIONAL_OPTS, ""); - defaults.put(ProcessProperties.CE_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"); - defaults.put(ProcessProperties.CE_JAVA_ADDITIONAL_OPTS, ""); - defaults.put(ProcessProperties.JDBC_MAX_ACTIVE, "60"); - defaults.put(ProcessProperties.JDBC_MAX_IDLE, "5"); - defaults.put(ProcessProperties.JDBC_MIN_IDLE, "2"); - defaults.put(ProcessProperties.JDBC_MAX_WAIT, "5000"); - defaults.put(ProcessProperties.JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS, "600000"); - defaults.put(ProcessProperties.JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS, "30000"); + defaults.put(SEARCH_JAVA_ADDITIONAL_OPTS, ""); + + defaults.put(PATH_DATA, "data"); + defaults.put(PATH_LOGS, "logs"); + defaults.put(PATH_TEMP, "temp"); + defaults.put(PATH_WEB, "web"); + + defaults.put(WEB_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"); + defaults.put(WEB_JAVA_ADDITIONAL_OPTS, ""); + defaults.put(CE_JAVA_OPTS, "-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError"); + defaults.put(CE_JAVA_ADDITIONAL_OPTS, ""); + defaults.put(JDBC_MAX_ACTIVE, "60"); + defaults.put(JDBC_MAX_IDLE, "5"); + defaults.put(JDBC_MIN_IDLE, "2"); + defaults.put(JDBC_MAX_WAIT, "5000"); + defaults.put(JDBC_MIN_EVICTABLE_IDLE_TIME_MILLIS, "600000"); + defaults.put(JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS, "30000"); + + defaults.put(CLUSTER_ENABLED, "false"); + defaults.put(CLUSTER_CE_DISABLED, "false"); + defaults.put(CLUSTER_WEB_DISABLED, "false"); + defaults.put(CLUSTER_SEARCH_DISABLED, "false"); + defaults.put(CLUSTER_NAME, ""); + defaults.put(CLUSTER_INTERFACES, ""); + defaults.put(CLUSTER_MEMBERS, ""); + defaults.put(CLUSTER_PORT, "9003"); + defaults.put(HAZELCAST_LOG_LEVEL, "WARN"); + return defaults; } private static Map<String, Integer> defaultPorts() { Map<String, Integer> defaults = new HashMap<>(); - defaults.put(ProcessProperties.SEARCH_PORT, 9001); + defaults.put(SEARCH_PORT, 9001); return defaults; } } diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java index 6bf327a3525..a79a218615a 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessUtils.java @@ -19,9 +19,6 @@ */ package org.sonar.process; -import org.apache.commons.io.IOUtils; -import org.slf4j.LoggerFactory; - import javax.annotation.Nullable; public class ProcessUtils { @@ -30,54 +27,6 @@ public class ProcessUtils { // only static stuff } - /** - * Do not abuse to this method. It uses exceptions to get status. - * @return false if process is null or terminated, else true. - */ - public static boolean isAlive(@Nullable Process process) { - boolean alive = false; - if (process != null) { - try { - process.exitValue(); - } catch (IllegalThreadStateException ignored) { - alive = true; - } - } - return alive; - } - - /** - * Send kill signal to stop process. Shutdown hooks are executed. It's the equivalent of SIGTERM on Linux. - * Correctly tested on Java 6 and 7 on both Mac/MSWindows - * @return true if the signal is sent, false if process is already down - */ - public static boolean sendKillSignal(@Nullable Process process) { - boolean sentSignal = false; - if (isAlive(process)) { - try { - process.destroy(); - sentSignal = true; - } catch (Exception e) { - LoggerFactory.getLogger(ProcessUtils.class).error("Fail to kill " + process, e); - } - } - return sentSignal; - } - - public static void closeStreams(@Nullable Process process) { - if (process!=null) { - IOUtils.closeQuietly(process.getInputStream()); - IOUtils.closeQuietly(process.getOutputStream()); - IOUtils.closeQuietly(process.getErrorStream()); - } - } - - public static void awaitTermination(Thread... threads) { - for (Thread thread : threads) { - awaitTermination(thread); - } - } - public static void awaitTermination(@Nullable Thread t) { if (t == null || Thread.currentThread() == t) { return; @@ -88,6 +37,7 @@ public class ProcessUtils { t.join(); } catch (InterruptedException e) { // ignore, keep on waiting for t to stop + Thread.currentThread().interrupt(); } } } diff --git a/server/sonar-process/src/test/java/org/sonar/process/FileUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java index a8bd64a6d8e..b8f7268c346 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/FileUtilsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/FileUtils2Test.java @@ -34,7 +34,7 @@ import org.junit.rules.TemporaryFolder; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assume.assumeTrue; -public class FileUtilsTest { +public class FileUtils2Test { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @Rule @@ -44,12 +44,12 @@ public class FileUtilsTest { public void cleanDirectory_throws_NPE_if_file_is_null() throws IOException { expectDirectoryCanNotBeNullNPE(); - FileUtils.cleanDirectory(null); + FileUtils2.cleanDirectory(null); } @Test public void cleanDirectory_does_nothing_if_argument_does_not_exist() throws IOException { - FileUtils.cleanDirectory(new File("/a/b/ToDoSSS")); + FileUtils2.cleanDirectory(new File("/a/b/ToDoSSS")); } @Test @@ -59,7 +59,7 @@ public class FileUtilsTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("'" + file.getAbsolutePath() + "' is not a directory"); - FileUtils.cleanDirectory(file); + FileUtils2.cleanDirectory(file); } @Test @@ -79,7 +79,7 @@ public class FileUtilsTest { // on supporting FileSystem, target will change if directory is recreated Object targetKey = getFileKey(target); - FileUtils.cleanDirectory(target.toFile()); + FileUtils2.cleanDirectory(target.toFile()); assertThat(target).isDirectory(); assertThat(childFile1).doesNotExist(); @@ -110,7 +110,7 @@ public class FileUtilsTest { Object targetKey = getFileKey(target); Object symLinkKey = getFileKey(symToDir); - FileUtils.cleanDirectory(symToDir.toFile()); + FileUtils2.cleanDirectory(symToDir.toFile()); assertThat(target).isDirectory(); assertThat(symToDir).isSymbolicLink(); @@ -124,7 +124,7 @@ public class FileUtilsTest { @Test public void deleteQuietly_does_not_fail_if_argument_is_null() { - FileUtils.deleteQuietly(null); + FileUtils2.deleteQuietly(null); } @Test @@ -132,7 +132,7 @@ public class FileUtilsTest { File file = new File(temporaryFolder.newFolder(), "blablabl"); assertThat(file).doesNotExist(); - FileUtils.deleteQuietly(file); + FileUtils2.deleteQuietly(file); } @Test @@ -149,7 +149,7 @@ public class FileUtilsTest { assertThat(childFile2).isRegularFile(); assertThat(childDir2).isDirectory(); - FileUtils.deleteQuietly(target.toFile()); + FileUtils2.deleteQuietly(target.toFile()); assertThat(target).doesNotExist(); assertThat(childFile1).doesNotExist(); @@ -168,7 +168,7 @@ public class FileUtilsTest { assertThat(file1).isRegularFile(); assertThat(symLink).isSymbolicLink(); - FileUtils.deleteQuietly(symLink.toFile()); + FileUtils2.deleteQuietly(symLink.toFile()); assertThat(symLink).doesNotExist(); assertThat(file1).isRegularFile(); @@ -178,14 +178,14 @@ public class FileUtilsTest { public void deleteDirectory_throws_NPE_if_argument_is_null() throws IOException { expectDirectoryCanNotBeNullNPE(); - FileUtils.deleteDirectory(null); + FileUtils2.deleteDirectory(null); } @Test public void deleteDirectory_does_not_fail_if_file_does_not_exist() throws IOException { File file = new File(temporaryFolder.newFolder(), "foo.d"); - FileUtils.deleteDirectory(file); + FileUtils2.deleteDirectory(file); } @Test @@ -195,7 +195,7 @@ public class FileUtilsTest { expectedException.expect(IOException.class); expectedException.expectMessage("Directory '" + file.getAbsolutePath() + "' is a file"); - FileUtils.deleteDirectory(file); + FileUtils2.deleteDirectory(file); } @Test @@ -211,7 +211,7 @@ public class FileUtilsTest { expectedException.expect(IOException.class); expectedException.expectMessage("Directory '" + symLink.toFile().getAbsolutePath() + "' is a symbolic link"); - FileUtils.deleteDirectory(symLink.toFile()); + FileUtils2.deleteDirectory(symLink.toFile()); } @Test @@ -228,7 +228,7 @@ public class FileUtilsTest { assertThat(childFile2).isRegularFile(); assertThat(childDir2).isDirectory(); - FileUtils.deleteQuietly(target.toFile()); + FileUtils2.deleteQuietly(target.toFile()); assertThat(target).doesNotExist(); assertThat(childFile1).doesNotExist(); diff --git a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java index fc773dde56a..cbb75706ced 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java @@ -19,9 +19,6 @@ */ package org.sonar.process; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.Objects; import org.junit.Test; @@ -54,18 +51,14 @@ public class LifecycleTest { @Test public void try_to_move_does_not_support_jumping_states() { - TestLifeCycleListener listener = new TestLifeCycleListener(); - Lifecycle lifecycle = new Lifecycle(listener); + Lifecycle lifecycle = new Lifecycle(); assertThat(lifecycle.getState()).isEqualTo(INIT); - assertThat(listener.getTransitions()).isEmpty(); assertThat(lifecycle.tryToMoveTo(STARTED)).isFalse(); assertThat(lifecycle.getState()).isEqualTo(INIT); - assertThat(listener.getTransitions()).isEmpty(); assertThat(lifecycle.tryToMoveTo(STARTING)).isTrue(); assertThat(lifecycle.getState()).isEqualTo(STARTING); - assertThat(listener.getTransitions()).containsOnly(new Transition(INIT, STARTING)); } @Test @@ -78,14 +71,11 @@ public class LifecycleTest { @Test public void can_move_to_STOPPING_from_STARTING_STARTED_OPERATIONAL_only() { for (State state : values()) { - TestLifeCycleListener listener = new TestLifeCycleListener(); - boolean tryToMoveTo = newLifeCycle(state, listener).tryToMoveTo(STOPPING); - if (state == STARTING || state == STARTED || state == OPERATIONAL) { + boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(STOPPING); + if (state == STARTING || state == STARTED || state == OPERATIONAL) { assertThat(tryToMoveTo).describedAs("from state " + state).isTrue(); - assertThat(listener.getTransitions()).containsOnly(new Transition(state, STOPPING)); } else { assertThat(tryToMoveTo).describedAs("from state " + state).isFalse(); - assertThat(listener.getTransitions()).isEmpty(); } } } @@ -93,73 +83,50 @@ public class LifecycleTest { @Test public void can_move_to_OPERATIONAL_from_STARTED_only() { for (State state : values()) { - TestLifeCycleListener listener = new TestLifeCycleListener(); - boolean tryToMoveTo = newLifeCycle(state, listener).tryToMoveTo(OPERATIONAL); + boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(OPERATIONAL); if (state == STARTED) { assertThat(tryToMoveTo).describedAs("from state " + state).isTrue(); - assertThat(listener.getTransitions()).containsOnly(new Transition(state, OPERATIONAL)); } else { assertThat(tryToMoveTo).describedAs("from state " + state).isFalse(); - assertThat(listener.getTransitions()).isEmpty(); } } } @Test public void can_move_to_STARTING_from_RESTARTING() { - TestLifeCycleListener listener = new TestLifeCycleListener(); - assertThat(newLifeCycle(RESTARTING, listener).tryToMoveTo(STARTING)).isTrue(); - assertThat(listener.getTransitions()).containsOnly(new Transition(RESTARTING, STARTING)); + assertThat(newLifeCycle(RESTARTING).tryToMoveTo(STARTING)).isTrue(); } - private static Lifecycle newLifeCycle(State state, TestLifeCycleListener... listeners) { + private static Lifecycle newLifeCycle(State state) { switch (state) { case INIT: - return new Lifecycle(listeners); + return new Lifecycle(); case STARTING: - return newLifeCycle(INIT, state, listeners); + return newLifeCycle(INIT, state); case STARTED: - return newLifeCycle(STARTING, state, listeners); + return newLifeCycle(STARTING, state); case OPERATIONAL: - return newLifeCycle(STARTED, state, listeners); + return newLifeCycle(STARTED, state); case RESTARTING: - return newLifeCycle(OPERATIONAL, state, listeners); + return newLifeCycle(OPERATIONAL, state); case STOPPING: - return newLifeCycle(OPERATIONAL, state, listeners); + return newLifeCycle(OPERATIONAL, state); case HARD_STOPPING: - return newLifeCycle(STARTING, state, listeners); + return newLifeCycle(STARTING, state); case STOPPED: - return newLifeCycle(STOPPING, state, listeners); + return newLifeCycle(STOPPING, state); default: throw new IllegalArgumentException("Unsupported state " + state); } } - private static Lifecycle newLifeCycle(State from, State to, TestLifeCycleListener... listeners) { + private static Lifecycle newLifeCycle(State from, State to) { Lifecycle lifecycle; - lifecycle = newLifeCycle(from, listeners); + lifecycle = newLifeCycle(from); assertThat(lifecycle.tryToMoveTo(to)).isTrue(); - Arrays.stream(listeners).forEach(TestLifeCycleListener::clear); return lifecycle; } - private static final class TestLifeCycleListener implements Lifecycle.LifecycleListener { - private final List<Transition> transitions = new ArrayList<>(); - - @Override - public void successfulTransition(State from, State to) { - transitions.add(new Transition(from, to)); - } - - public List<Transition> getTransitions() { - return transitions; - } - - public void clear() { - this.transitions.clear(); - } - } - private static final class Transition { private final State from; private final State to; diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java index eff0d44763c..d1f872b904d 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessUtilsTest.java @@ -30,7 +30,7 @@ import static org.sonar.process.ProcessUtils.awaitTermination; public class ProcessUtilsTest { @Rule - public Timeout timeout= Timeout.seconds(5); + public Timeout timeout = Timeout.seconds(5); @Test public void private_constructor() { @@ -39,7 +39,7 @@ public class ProcessUtilsTest { @Test public void awaitTermination_does_not_fail_on_null_Thread_argument() { - awaitTermination((Thread) null); + awaitTermination(null); } @Test @@ -50,22 +50,14 @@ public class ProcessUtilsTest { @Test public void awaitTermination_ignores_interrupted_exception_of_current_thread() throws InterruptedException { final EverRunningThread runningThread = new EverRunningThread(); - final Thread safeJoiner = new Thread() { - @Override - public void run() { - awaitTermination(runningThread); + final Thread safeJoiner = new Thread(() -> awaitTermination(runningThread)); + final Thread simpleJoiner = new Thread(() -> { + try { + runningThread.join(); + } catch (InterruptedException e) { + System.err.println("runningThread interruption detected in SimpleJoiner"); } - }; - final Thread simpleJoiner = new Thread() { - @Override - public void run() { - try { - runningThread.join(); - } catch (InterruptedException e) { - System.err.println("runningThread interruption detected in SimpleJoiner"); - } - } - }; + }); runningThread.start(); safeJoiner.start(); simpleJoiner.start(); @@ -81,7 +73,7 @@ public class ProcessUtilsTest { } // safeJoiner must still be alive - assertThat(safeJoiner.isAlive()).isTrue() ; + assertThat(safeJoiner.isAlive()).isTrue(); // stop runningThread runningThread.stopIt(); @@ -94,11 +86,6 @@ public class ProcessUtilsTest { safeJoiner.join(); } - @Test - public void awaitTermination_of_vararg_does_not_fail_when_there_is_a_null_or_current_thread() { - awaitTermination(null, Thread.currentThread(), null); - } - private static class EverRunningThread extends Thread { private volatile boolean stop = false; diff --git a/server/sonar-process/test-jar-with-dependencies.xml b/server/sonar-process/test-jar-with-dependencies.xml deleted file mode 100644 index 832c66cc0be..00000000000 --- a/server/sonar-process/test-jar-with-dependencies.xml +++ /dev/null @@ -1,19 +0,0 @@ -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - <id>test-jar-with-dependencies</id> - <formats> - <format>jar</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <dependencySets> - <dependencySet> - <outputDirectory>/</outputDirectory> - <useProjectArtifact>true</useProjectArtifact> - <!-- we're creating the test-jar as an attachement --> - <useProjectAttachments>true</useProjectAttachments> - <unpack>true</unpack> - <scope>test</scope> - </dependencySet> - </dependencySets> -</assembly> |