Skip to content

Commit

Permalink
Fix code issues in exec package
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Aug 20, 2024
1 parent b0d5fe1 commit e92b125
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Exec {
private static final Pattern ERROR_PATTERN = Pattern.compile("Error from server \\(([a-zA-Z0-9]+)\\):");
private static final Pattern INVALID_PATTERN = Pattern
.compile("The ([a-zA-Z0-9]+) \"([a-z0-9.-]+)\" is invalid:");
private static final Pattern PATH_SPLITTER = Pattern.compile(System.getProperty("path.separator"));
private static final Pattern PATH_SPLITTER = Pattern.compile(File.pathSeparator);
private static final int MAXIMUM_EXEC_LOG_CHARACTER_SIZE = 2000;
private static final Object LOCK = new Object();

Expand Down Expand Up @@ -271,7 +271,7 @@ public static ExecResult exec(String input, List<String> command, Set<EnvVar> en
*/
public int execute(String input, List<String> commands, Set<EnvVar> envVars, long timeoutMs)
throws IOException, InterruptedException, ExecutionException {
LOGGER.trace("Running command - " + join(" ", commands.toArray(new String[0])));
LOGGER.trace("Running command - {}", join(" ", commands.toArray(new String[0])));
ProcessBuilder builder = new ProcessBuilder();
builder.command(commands);
if (envVars != null) {
Expand Down Expand Up @@ -432,7 +432,7 @@ public Future<String> read() {
while (scanner.hasNextLine()) {
data.append(scanner.nextLine());
if (appendLineSeparator) {
data.append(System.getProperty("line.separator"));
data.append(System.lineSeparator());
}
}
scanner.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*/
package io.skodjob.testframe.executor;

import java.io.Serial;
import java.io.Serializable;

/**
* Represents the result of an execution.
*/
public class ExecResult implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

/**
Expand Down Expand Up @@ -84,11 +86,9 @@ public String err() {
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ExecResult{");
sb.append("returnCode=").append(returnCode);
sb.append(", stdOut='").append(stdOut).append('\'');
sb.append(", stdErr='").append(stdErr).append('\'');
sb.append('}');
return sb.toString();
return "ExecResult{" + "returnCode=" + returnCode +
", stdOut='" + stdOut + '\'' +
", stdErr='" + stdErr + '\'' +
'}';
}
}

0 comments on commit e92b125

Please sign in to comment.