fixes coverity issue 141838

This commit is contained in:
Sebastian Stenzel
2016-08-14 14:39:05 +02:00
parent 505b6542c7
commit 3b3ebd2196

View File

@@ -61,13 +61,18 @@ final class CommandRunner {
static CommandResult execute(Script script, long timeout, TimeUnit unit) throws CommandFailedException {
try {
final List<String> env = script.environment().entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList());
final String[] lines = script.getLines();
if (lines.length == 0) {
throw new IllegalArgumentException("Invalid script");
}
CommandResult result = null;
for (final String line : script.getLines()) {
for (final String line : lines) {
final String[] cmds = ArrayUtils.add(determineCli(), line);
final Process proc = Runtime.getRuntime().exec(cmds, env.toArray(new String[0]));
result = run(proc, timeout, unit);
result.assertOk();
}
assert result != null;
return result;
} catch (IOException e) {
throw new CommandFailedException(e);