Skip to content

Commit

Permalink
Fix code issues in exec package (#169)
Browse files Browse the repository at this point in the history
## Description

Fix few issues in exec package in logging etc...


## Type of Change

Please delete options that are not relevant.

* Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit/integration tests pass locally with my
changes

Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored Aug 20, 2024
1 parent b0d5fe1 commit 5c419b3
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 5c419b3

Please sign in to comment.