Skip to content

Commit 991393e

Browse files
committed
Update ProcessExecutor.java
1 parent 9638ada commit 991393e

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

microsphere-java-core/src/main/java/io/microsphere/process/ProcessExecutor.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ public class ProcessExecutor {
2727

2828
private final Runtime runtime = getRuntime();
2929

30-
private final String command;
30+
private final String commandLine;
3131

32-
private final String arguments;
32+
private final String options;
3333

3434
private boolean finished;
3535

3636
/**
3737
* Constructor
3838
*
39-
* @param processName command
40-
* @param arguments process arguments
39+
* @param command command
40+
* @param options command options
4141
*/
42-
public ProcessExecutor(String processName, String... arguments) {
43-
StringBuilder argumentsBuilder = new StringBuilder();
44-
if (arguments != null) {
45-
for (String argument : arguments) {
46-
argumentsBuilder.append(" ").append(argument);
42+
public ProcessExecutor(String command, String... options) {
43+
StringBuilder optionsBuilder = new StringBuilder();
44+
if (options != null) {
45+
for (String argument : options) {
46+
optionsBuilder.append(" ").append(argument);
4747
}
4848
}
49-
this.arguments = argumentsBuilder.toString();
50-
this.command = processName + this.arguments;
49+
this.options = optionsBuilder.toString();
50+
this.commandLine = command + this.options;
5151
}
5252

5353
/**
@@ -76,7 +76,7 @@ public void execute(OutputStream outputStream) throws IOException {
7676
* @throws TimeoutException if the execution is timeout over specified <code>timeoutInMilliseconds</code>
7777
*/
7878
public void execute(OutputStream outputStream, long timeoutInMilliseconds) throws IOException, TimeoutException {
79-
Process process = runtime.exec(command);
79+
Process process = runtime.exec(commandLine);
8080
long startTime = currentTimeMillis();
8181
long endTime = -1L;
8282
InputStream processInputStream = process.getInputStream();
@@ -92,7 +92,7 @@ public void execute(OutputStream outputStream, long timeoutInMilliseconds) throw
9292
throw new TimeoutException(message);
9393
}
9494
try {
95-
processManager.addUnfinishedProcess(process, arguments);
95+
processManager.addUnfinishedProcess(process, options);
9696
while (processInputStream.available() > 0) {
9797
outputStream.write(processInputStream.read());
9898
}
@@ -110,7 +110,7 @@ public void execute(OutputStream outputStream, long timeoutInMilliseconds) throw
110110
waitFor(waitForTimeInSecond);
111111
endTime = currentTimeMillis();
112112
} finally {
113-
processManager.removeUnfinishedProcess(process, arguments);
113+
processManager.removeUnfinishedProcess(process, options);
114114
}
115115
}
116116
}

0 commit comments

Comments
 (0)