aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src
diff options
context:
space:
mode:
authorgjoranv <gv@yahoo-inc.com>2017-03-02 13:24:48 +0100
committergjoranv <gv@yahoo-inc.com>2017-03-02 13:24:48 +0100
commit165165f56b58e0d8320ccd3d6174754ab22e4794 (patch)
tree345c66a0eff8e7884d262ded25688f6f2b5aaa2b /vespajlib/src
parentcba366fe6ceaa445d46f015f18885b098c13c08e (diff)
Add javadoc.
Diffstat (limited to 'vespajlib/src')
-rw-r--r--vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java b/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java
index 564ee5ea3ac..2837372820b 100644
--- a/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java
+++ b/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java
@@ -15,6 +15,8 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit;
/**
+ * Configurable system command executor that captures stdout and stderr.
+ *
* @author gjoranv
* @author bjorncs
*/
@@ -46,11 +48,22 @@ public class ProcessExecutor {
public final int timeoutSeconds;
private final int[] successExitCodes;
+ /**
+ * Convenience method to execute a process with no input data. See {@link #execute(String, String)} for details.
+ */
public Optional<ProcessResult> execute(String command) throws IOException {
return execute(command, null);
}
- public Optional<ProcessResult> execute(String command, String processInput) throws IOException {
+ /**
+ * Executes the given command synchronously.
+ *
+ * @param command The command to execute.
+ * @param processInput Input provided to the process.
+ * @return The result of the execution, or empty if the process does not terminate within the timeout set for this executor.
+ * @throws IOException if the process execution failed.
+ */
+ public Optional<ProcessResult> execute(String command, String processInput) throws IOException {
ByteArrayOutputStream processErr = new ByteArrayOutputStream();
ByteArrayOutputStream processOut = new ByteArrayOutputStream();