Skip to content

minor: [JDK upgrade] Update forking task runner to use bin/run-java#19709

Merged
cryptoe merged 3 commits into
apache:masterfrom
cryptoe:support_newer_java_peons
Jul 21, 2026
Merged

minor: [JDK upgrade] Update forking task runner to use bin/run-java#19709
cryptoe merged 3 commits into
apache:masterfrom
cryptoe:support_newer_java_peons

Conversation

@cryptoe

@cryptoe cryptoe commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The druid documentation mentions setting JAVA_HOME should be sufficient for all druid processes to use the updated java versions.

The launched peons from the middle manager were not honoring that.

Added logic so that middle managers start honoring JAVA_HOME by using the bin/java script which should be present in the working directory.

Update logic is:

  • if user has specified a command (i.e. if config.getJavaCommand is not null), use that.
  • if bin/run-java exists, use that
  • use java

The existence check is reliable because peons inherit the parent process's working directory. The default config value and docs remain java; the doc note describes the auto-upgrade behavior.

@cryptoe cryptoe added this to the 38.0.0 milestone Jul 20, 2026
@cryptoe cryptoe added the Upgrade note Behavior change that requires an upgrade note label Jul 20, 2026

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch, @cryptoe ! Left a suggestion.

Comment thread docs/configuration/index.md Outdated
|`druid.indexer.runner.allowedPrefixes`|Whitelist of prefixes for configs that can be passed down to child peons.|`com.metamx`, `druid`, `org.apache.druid`, `user.timezone`, `file.encoding`, `java.io.tmpdir`, `hadoop`|
|`druid.indexer.runner.classpath`|Java classpath for the peon.|`System.getProperty("java.class.path")`|
|`druid.indexer.runner.javaCommand`|Command required to execute java.|java|
|`druid.indexer.runner.javaCommand`| Command required to execute java. When left at the *default*, Druid uses the bundled `bin/run-java` script if it is present in the working directory (it honors the `DRUID_JAVA_HOME`/`JAVA_HOME` environment variables), otherwise it falls back to `java` on the `PATH`. |java|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`druid.indexer.runner.javaCommand`| Command required to execute java. When left at the *default*, Druid uses the bundled `bin/run-java` script if it is present in the working directory (it honors the `DRUID_JAVA_HOME`/`JAVA_HOME` environment variables), otherwise it falls back to `java` on the `PATH`. |java|
|`druid.indexer.runner.javaCommand`| Command required to execute java. If not specified, Druid uses the bundled `bin/run-java` script if it is present in the working directory (it honors the `DRUID_JAVA_HOME`/`JAVA_HOME` environment variables), otherwise it falls back to `java` on the `PATH`. |java|

*/
public static String getJavaCommand(String configuredJavaCommand, File workingDir)
{
if (ForkingTaskRunnerConfig.DEFAULT_JAVA_COMMAND.equals(configuredJavaCommand)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we distinguish between the case where the user has actually specified java as the command vs the default?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we could do is not assign any default in the config object, and do the following in this method:

  • if user has specified a command (i.e. if config.getJavaCommand is not null), use that.
  • if bin/run-java exists, use that
  • use java

This way, the entire fallback logic exists in one place.

{
final File workingDir = temporaryFolder.newFolder();
final File binDir = new File(workingDir, "bin");
Assert.assertTrue(binDir.mkdirs());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid use of forbidden API

Suggested change
Assert.assertTrue(binDir.mkdirs());
Assert.assertTrue(FileUtils(binDir.mkdirp()));

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1
Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 4 of 4 changed files.


This is an automated review by Codex GPT-5.6-Sol

public static String getJavaCommand(String configuredJavaCommand, File workingDir)
{
if (ForkingTaskRunnerConfig.DEFAULT_JAVA_COMMAND.equals(configuredJavaCommand)
&& new File(workingDir, RUN_JAVA_COMMAND).exists()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Check launcher executability before selecting it

exists() also accepts non-executable files and directories. In installations where mode bits were not preserved, peon startup now selects bin/run-java and fails in ProcessBuilder instead of falling back to the working java command on PATH. Require a regular executable file before returning the bundled launcher, and cover the non-executable case.

@cryptoe

cryptoe commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @kfaraz . Addressed all your comments. Please take a look since this should probably be going in druid 38 as we have bumped up the min JDK version to 21.

@kfaraz kfaraz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cryptoe
cryptoe merged commit 3ee535b into apache:master Jul 21, 2026
63 of 64 checks passed
@github-actions github-actions Bot modified the milestones: 38.0.0, 39.0.0 Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Documentation Area - Ingestion Upgrade note Behavior change that requires an upgrade note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants