Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code issues in exec package #169

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 + '\'' +
'}';
}
}
Loading