Skip to content

Commit

Permalink
SAMZA-2798: Populate worker.opts in environment variable only if avai…
Browse files Browse the repository at this point in the history
…lable (apache#1693)

Description
Populate worker.opts in the environment variable only if available in the configs.

Changes
Check if worker.opts is present and then add it to environment variable

Tests
Updated unit tests
  • Loading branch information
mynameborat committed Nov 22, 2023
1 parent 415637a commit 6dcd505
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ public Map<String, String> buildEnvironment() {
envBuilder.put(ShellCommandConfig.ENV_CONTAINER_ID, this.id);
envBuilder.put(ShellCommandConfig.ENV_COORDINATOR_URL, this.url.toString());
envBuilder.put(ShellCommandConfig.ENV_JAVA_OPTS, shellCommandConfig.getTaskOpts().orElse(""));
envBuilder.put(ShellCommandConfig.WORKER_JVM_OPTS, shellCommandConfig.getWorkerOpts().orElse(""));
envBuilder.put(ShellCommandConfig.ENV_ADDITIONAL_CLASSPATH_DIR,
shellCommandConfig.getAdditionalClasspathDir().orElse(""));
shellCommandConfig.getWorkerOpts()
.ifPresent(workerOpts -> envBuilder.put(ShellCommandConfig.WORKER_JVM_OPTS, workerOpts));
shellCommandConfig.getJavaHome().ifPresent(javaHome -> envBuilder.put(ShellCommandConfig.ENV_JAVA_HOME, javaHome));
return envBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void testBasicBuild() throws MalformedURLException {
ShellCommandConfig.ENV_CONTAINER_ID, "1",
ShellCommandConfig.ENV_COORDINATOR_URL, URL_STRING,
ShellCommandConfig.ENV_JAVA_OPTS, "",
ShellCommandConfig.WORKER_JVM_OPTS, "",
ShellCommandConfig.ENV_ADDITIONAL_CLASSPATH_DIR, "");
// assertions when command path is not set
assertEquals("foo", shellCommandBuilder.buildCommand());
Expand Down

0 comments on commit 6dcd505

Please sign in to comment.