Skip to content

Commit

Permalink
Building a command line with string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-mcgoldrick committed Jul 24, 2024
1 parent 718287f commit ba393e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -97,9 +98,8 @@ public void startTest(final StandaloneAgentRequest request) {
}
}
// now start the harness
String cmd = API_HARNESS_COMMAND + " -http=" + controllerBase + " -jobId=" + request.getJobId()
+ " -stopBehavior=" + request.getStopBehavior();
LOG.info("Starting apiharness with command: " + cmd);
String[] cmd = {API_HARNESS_COMMAND, " -http=", controllerBase, " -jobId=", request.getJobId(), " -stopBehavior=", request.getStopBehavior()};
LOG.info("Starting apiharness with command: {}", Arrays.toString(cmd));
currentAvailability.setAvailabilityStatus(AgentAvailabilityStatus.RUNNING_JOB);
sendAvailability();
Process exec = Runtime.getRuntime().exec(cmd);
Expand All @@ -108,7 +108,7 @@ public void startTest(final StandaloneAgentRequest request) {
sendAvailability();
//
} catch (Exception e) {
LOG.error("Error in AgentStartup " + e, e);
LOG.error("Error in AgentStartup {}", e, e);
currentAvailability.setAvailabilityStatus(AgentAvailabilityStatus.AVAILABLE);
try {
sendAvailability();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public void run() {
String jvmArgs = AmazonUtil.getUserDataAsMap().get(TankConstants.KEY_JVM_ARGS);
logger.info("Starting apiharness with command: "
+ API_HARNESS_COMMAND + " -http=" + controllerBaseUrl + " " + jvmArgs);
Runtime.getRuntime().exec(API_HARNESS_COMMAND + " -http=" + controllerBaseUrl + " " + jvmArgs);
Runtime.getRuntime().exec(
new String[] {API_HARNESS_COMMAND, "-http=", controllerBaseUrl, jvmArgs});
} catch (ConnectException ce) {
logger.error("Error creating connection to "
+ controllerBaseUrl + " : this is normal during the bake : " + ce.getMessage());
Expand Down

0 comments on commit ba393e1

Please sign in to comment.