]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7168 fix quality flaw in AllProcessesCommands
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 8 Feb 2016 08:45:06 +0000 (09:45 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 8 Feb 2016 08:45:45 +0000 (09:45 +0100)
server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java
server/sonar-process/src/main/java/org/sonar/process/AllProcessesCommands.java
server/sonar-process/src/main/java/org/sonar/process/DefaultProcessCommands.java
server/sonar-process/src/test/java/org/sonar/process/AllProcessesCommandsTest.java

index 403ec9a3b60b11f2d288091980e1c135a35607b2..7a5869abb38d66dafafafc756257894bc9514c73 100644 (file)
@@ -52,7 +52,7 @@ public class JavaProcessLauncher {
   ProcessRef launch(JavaCommand command) {
     Process process = null;
     try {
-      ProcessCommands commands = allProcessesCommands.getProcessCommand(command.getProcessIndex(), true);
+      ProcessCommands commands = allProcessesCommands.createAfterClean(command.getProcessIndex());
 
       ProcessBuilder processBuilder = create(command);
       LoggerFactory.getLogger(getClass()).info("Launch process[{}]: {}",
index 85f043a4306c17f8742ae28f6effd6ef3f7af7a1..e174984a88b2cb3fa7a3804a15425dfb325e973f 100644 (file)
@@ -86,7 +86,15 @@ public class AllProcessesCommands {
     }
   }
 
-  public ProcessCommands getProcessCommand(int processNumber, boolean clean) {
+  public ProcessCommands create(int processNumber) {
+    return createForProcess(processNumber, false);
+  }
+
+  public ProcessCommands createAfterClean(int processNumber) {
+    return createForProcess(processNumber, true);
+  }
+
+  private ProcessCommands createForProcess(int processNumber, boolean clean) {
     checkProcessNumber(processNumber);
     ProcessCommands processCommands = new ProcessCommandsImpl(processNumber);
     if (clean) {
index 06c3f9510d4c01fb3387adfc9cfe86aae52a7506..68ca4a9806321965ca662c02195acab1b0cfd536 100644 (file)
@@ -36,7 +36,7 @@ public class DefaultProcessCommands implements ProcessCommands {
 
   public DefaultProcessCommands(File directory, int processNumber, boolean clean) {
     this.allProcessesCommands = new AllProcessesCommands(directory);
-    this.delegate = allProcessesCommands.getProcessCommand(processNumber, clean);
+    this.delegate = clean ? allProcessesCommands.createAfterClean(processNumber) : allProcessesCommands.create(processNumber);
   }
 
   @Override
index d981876708e895f8864f036db9a2db48c3e618f8..625ab016e1dcc87385eb206b20af699caf49daf4 100644 (file)
@@ -134,7 +134,7 @@ public class AllProcessesCommandsTest {
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("Process number " + processNumber + " is not valid");
 
-    allProcessesCommands.getProcessCommand(processNumber, true);
+    allProcessesCommands.createAfterClean(processNumber);
   }
 
   @Test
@@ -147,6 +147,6 @@ public class AllProcessesCommandsTest {
     expectedException.expect(IllegalArgumentException.class);
     expectedException.expectMessage("Process number " + processNumber + " is not valid");
 
-    allProcessesCommands.getProcessCommand(processNumber, true);
+    allProcessesCommands.createAfterClean(processNumber);
   }
 }