Skip to content

Commit 8ed3572

Browse files
authored
SAMZA-2798: Populate worker.opts in environment variable only if available (#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
1 parent e1816f3 commit 8ed3572

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

samza-core/src/main/java/org/apache/samza/job/ShellCommandBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public Map<String, String> buildEnvironment() {
4444
envBuilder.put(ShellCommandConfig.ENV_CONTAINER_ID, this.id);
4545
envBuilder.put(ShellCommandConfig.ENV_COORDINATOR_URL, this.url.toString());
4646
envBuilder.put(ShellCommandConfig.ENV_JAVA_OPTS, shellCommandConfig.getTaskOpts().orElse(""));
47-
envBuilder.put(ShellCommandConfig.WORKER_JVM_OPTS, shellCommandConfig.getWorkerOpts().orElse(""));
4847
envBuilder.put(ShellCommandConfig.ENV_ADDITIONAL_CLASSPATH_DIR,
4948
shellCommandConfig.getAdditionalClasspathDir().orElse(""));
49+
shellCommandConfig.getWorkerOpts()
50+
.ifPresent(workerOpts -> envBuilder.put(ShellCommandConfig.WORKER_JVM_OPTS, workerOpts));
5051
shellCommandConfig.getJavaHome().ifPresent(javaHome -> envBuilder.put(ShellCommandConfig.ENV_JAVA_HOME, javaHome));
5152
return envBuilder.build();
5253
}

samza-core/src/test/java/org/apache/samza/job/TestShellCommandBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void testBasicBuild() throws MalformedURLException {
4545
ShellCommandConfig.ENV_CONTAINER_ID, "1",
4646
ShellCommandConfig.ENV_COORDINATOR_URL, URL_STRING,
4747
ShellCommandConfig.ENV_JAVA_OPTS, "",
48-
ShellCommandConfig.WORKER_JVM_OPTS, "",
4948
ShellCommandConfig.ENV_ADDITIONAL_CLASSPATH_DIR, "");
5049
// assertions when command path is not set
5150
assertEquals("foo", shellCommandBuilder.buildCommand());

0 commit comments

Comments
 (0)