Skip to content

Pass Spark job server JVM args#39242

Merged
Abacn merged 1 commit into
apache:masterfrom
aIbrahiim:fix-spark-job-server-java21-add-opens
Jul 8, 2026
Merged

Pass Spark job server JVM args#39242
Abacn merged 1 commit into
apache:masterfrom
aIbrahiim:fix-spark-job-server-java21-add-opens

Conversation

@aIbrahiim

@aIbrahiim aIbrahiim commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Fixes: #30602
Successful run: https://github.com/apache/beam/actions/runs/28941534332

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@aIbrahiim aIbrahiim reopened this Jul 8, 2026
@aIbrahiim
aIbrahiim force-pushed the fix-spark-job-server-java21-add-opens branch from 149a3c2 to 38a618d Compare July 8, 2026 12:10
@aIbrahiim
aIbrahiim marked this pull request as ready for review July 8, 2026 14:12
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the ability to pass custom JVM arguments to the Spark job server. This change is primarily aimed at resolving compatibility issues with Java 17 and newer, where specific module access flags are required. The implementation includes logic to automatically detect the Java version and apply the necessary 'add-opens' flags, while also updating the supporting shell scripts to handle these arguments during the job server lifecycle.

Highlights

  • JVM Argument Support: Added support for passing custom JVM arguments to the Spark job server, enabling necessary flags for newer Java versions.
  • Java 17 Compatibility: Implemented automatic detection of Java 17+ to inject required '--add-opens' flags, ensuring compatibility with modern Java environments.
  • Script Updates: Updated the 'run_job_server.sh' script to accept and apply the new '--jvm_args' parameter during server startup.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for passing JVM arguments (such as --add-opens flags for Java 17+) to the Spark Job Server. It updates the Gradle setup task to dynamically determine the Java version and pass these arguments, and modifies run_job_server.sh to accept and apply them. The review feedback highlights potential issues with unquoted $JVM_ARGS in the shell script leading to word-splitting or unbound variable errors, and a potential NumberFormatException in the Gradle build file when parsing the testJavaVersion property.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


echo "Launching job server @ $JOB_PORT ..."
"$JAVA_CMD" -jar $JOB_SERVER_JAR --job-port=$JOB_PORT --artifact-port=$ARTIFACT_PORT --expansion-port=0 $ADDITIONAL_ARGS >$TEMP_DIR/$FILE_BASE.log 2>&1 </dev/null &
"$JAVA_CMD" $JVM_ARGS -jar $JOB_SERVER_JAR --job-port=$JOB_PORT --artifact-port=$ARTIFACT_PORT --expansion-port=0 $ADDITIONAL_ARGS >$TEMP_DIR/$FILE_BASE.log 2>&1 </dev/null &

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.

medium

When $JVM_ARGS is unquoted, it undergoes word splitting, which is necessary here to pass multiple JVM arguments (like --add-opens) as separate parameters to the java command. However, if $JVM_ARGS is empty or unset, this can sometimes lead to unexpected behavior depending on shell settings, or if any of the arguments contain spaces.

To ensure robustness and avoid issues with empty values, it is safer to use an array for arguments in bash, or explicitly handle the expansion. Since this script is executed via sh (which might be dash or bash depending on the system), we should be careful. If we are sure it's run with bash (the shebang of run_job_server.sh is likely #!/bin/bash), using a bash array is the most robust way to handle list of arguments with potential spaces. If it must remain a string, we should ensure JVM_ARGS is initialized to an empty string at the top of the script to prevent unbound variable errors if set -u is used.

def artifactPort = BeamModulePlugin.getRandomPort()

def sparkJobServerJvmArgs() {
def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion') as int) : JavaVersion.current().majorVersion.toInteger()

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.

medium

In Groovy/Gradle, using as int on a property that might be a String can throw a NumberFormatException if the property is not a valid integer. Additionally, JavaVersion.current().majorVersion is already a String, so calling .toInteger() on it is safe, but we should make sure testJavaVersion is safely parsed.

Consider using Integer.parseInt() or a safe cast with a fallback to avoid potential build failures if testJavaVersion is configured incorrectly.

  def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion').toString().toInteger()) : JavaVersion.current().majorVersion.toInteger()

@Amar3tto
Amar3tto requested a review from Abacn July 8, 2026 14:41

@Abacn Abacn 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!

@Abacn
Abacn merged commit 1f4f559 into apache:master Jul 8, 2026
146 of 151 checks passed
@aIbrahiim
aIbrahiim deleted the fix-spark-job-server-java21-add-opens branch July 8, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The PostCommit XVR Spark3 job is flaky

2 participants