diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-02-08 09:45:06 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-02-08 09:45:45 +0100 |
commit | fab948761d972de69b4674f40052f44ca803d120 (patch) | |
tree | 61a3d75798ebd69e5475f2e3e682dc2eaa6ff77c /server | |
parent | 6aff1b068d8d68493d357ca48c204dac1dc0ddea (diff) | |
download | sonarqube-fab948761d972de69b4674f40052f44ca803d120.tar.gz sonarqube-fab948761d972de69b4674f40052f44ca803d120.zip |
SONAR-7168 fix quality flaw in AllProcessesCommands
Diffstat (limited to 'server')
4 files changed, 13 insertions, 5 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java index 403ec9a3b60..7a5869abb38 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/JavaProcessLauncher.java @@ -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[{}]: {}", diff --git a/server/sonar-process/src/main/java/org/sonar/process/AllProcessesCommands.java b/server/sonar-process/src/main/java/org/sonar/process/AllProcessesCommands.java index 85f043a4306..e174984a88b 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/AllProcessesCommands.java +++ b/server/sonar-process/src/main/java/org/sonar/process/AllProcessesCommands.java @@ -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) { diff --git a/server/sonar-process/src/main/java/org/sonar/process/DefaultProcessCommands.java b/server/sonar-process/src/main/java/org/sonar/process/DefaultProcessCommands.java index 06c3f9510d4..68ca4a98063 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/DefaultProcessCommands.java +++ b/server/sonar-process/src/main/java/org/sonar/process/DefaultProcessCommands.java @@ -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 diff --git a/server/sonar-process/src/test/java/org/sonar/process/AllProcessesCommandsTest.java b/server/sonar-process/src/test/java/org/sonar/process/AllProcessesCommandsTest.java index d981876708e..625ab016e1d 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/AllProcessesCommandsTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/AllProcessesCommandsTest.java @@ -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); } } |