Skip to content

Bump CI Java version to Java21#39205

Open
Abacn wants to merge 1 commit into
masterfrom
bumpjava21
Open

Bump CI Java version to Java21#39205
Abacn wants to merge 1 commit into
masterfrom
bumpjava21

Conversation

@Abacn

@Abacn Abacn commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Attempted in #38931 earlier, now more and more components requires Java17+ (IcebegIO, Deltalake, JmsIO - #38729).

Moving CI to Java21 while the bytecode compatibility of built artifacts remains unchanged.

Merge after current release (2.75.0) finalized to avoid disruptions to ongoing release

Fix #34056

Please add a meaningful description for your change here


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.

@Abacn

Abacn commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

list of failing tests in precommit:

:runners:direct-java:test
:runners:prism:java:test
:runners:spark:3:test
:runners:java-fn-execution:test
:sdks:java:core:test
:sdks:java:extensions:arrow:test
:sdks:java:extensions:avro:test
:sdks:java:extensions:python:test
:sdks:java:io:cassandra:test
:sdks:java:io:csv:test
:sdks:java:io:cdap:test
:examples:java:sparkRunnerPreCommit
:sdks:java:io:hcatalog:test
:runners:direct-java:needsRunnerTests
:sdks:java:io:kafka:analyzeClassesDependencies
:sdks:java:io:influxdb:test
:sdks:java:io:hbase:test
:sdks:java:io:singlestore:test
:sdks:java:io:kafka:test
:runners:flink:1.19:test
:runners:flink:1.20:test

@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 migrates the project's CI environment to Java 21. The changes encompass updating build configurations, injecting required JVM arguments to bypass module encapsulation, and refactoring test suites to accommodate changes in Java's reflection and exception reporting. These updates ensure the project remains compatible with modern Java standards while maintaining bytecode stability.

Highlights

  • CI Infrastructure Upgrade: Upgraded the CI environment to Java 21 and updated the Gradle version to 8.14.3 to ensure compatibility with modern Java requirements.
  • Module Encapsulation Fixes: Added necessary JVM arguments (--add-opens) across various modules to handle Java 17+ module encapsulation, particularly for reflection and memory access.
  • Test Suite Adjustments: Updated numerous tests to account for changes in exception message formatting and annotation string representations introduced in newer Java versions.
  • Dependency Cleanup: Removed PowerMock from InfluxDB tests due to incompatibility with newer Java versions and updated date handling logic to ensure UTC consistency.
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.

Ignored Files
  • Ignored by pattern: .github/workflows/** (25)
    • .github/workflows/README.md
    • .github/workflows/beam_PerformanceTests_xlang_KafkaIO_Python.yml
    • .github/workflows/beam_PostCommit_Java_Jpms_Dataflow.yml
    • .github/workflows/beam_PostCommit_Java_Jpms_Direct.yml
    • .github/workflows/beam_PostCommit_Python_Xlang_Gcp_Dataflow.yml
    • .github/workflows/beam_PostCommit_Python_Xlang_Gcp_Direct.yml
    • .github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml
    • .github/workflows/beam_PostCommit_Python_Xlang_IO_Direct.yml
    • .github/workflows/beam_PostCommit_TransformService_Direct.yml
    • .github/workflows/beam_PostCommit_XVR_Direct.yml
    • .github/workflows/beam_PostCommit_XVR_Flink.yml
    • .github/workflows/beam_PostCommit_XVR_GoUsingJava_Dataflow.yml
    • .github/workflows/beam_PostCommit_XVR_JavaUsingPython_Dataflow.yml
    • .github/workflows/beam_PostCommit_XVR_PythonUsingJavaSQL_Dataflow.yml
    • .github/workflows/beam_PostCommit_XVR_PythonUsingJava_Dataflow.yml
    • .github/workflows/beam_PostCommit_XVR_Spark3.yml
    • .github/workflows/beam_PreCommit_Java_Cassandra_IO_Direct.yml
    • .github/workflows/beam_PreCommit_Java_Debezium_IO_Direct.yml
    • .github/workflows/beam_PreCommit_Java_Examples_Dataflow_Java11.yml
    • .github/workflows/beam_PreCommit_Java_Flink_Versions.yml
    • .github/workflows/beam_PreCommit_Java_HCatalog_IO_Direct.yml
    • .github/workflows/beam_PreCommit_Java_IOs_Direct.yml
    • .github/workflows/beam_PreCommit_Java_Spark_Versions.yml
    • .github/workflows/beam_PreCommit_Kotlin_Examples.yml
    • .github/workflows/beam_Publish_Beam_SDK_Snapshots.yml
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.

@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 prepares the codebase for Java 17+ compatibility by upgrading Java and Gradle versions in GitHub Actions and Dockerfiles, adding necessary JVM arguments for module access, and updating tests to handle Java 17+ specific behaviors. Additionally, it removes PowerMock from InfluxDbIO tests in favor of Mockito. The reviewer recommends declaring the newly introduced static connection factory in InfluxDbIO as volatile for thread safety, checking for null on Class.getCanonicalName() in ApiSurface to prevent potential issues, and simplifying the testJavaVersion resolution logic in several Gradle files using Groovy's elvis operator.

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.

Comment on lines +645 to +646
private static @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB>
connectionFactory = 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.

high

The static connectionFactory field is set by the test thread and read by the pipeline execution threads (e.g., when running with DirectRunner). To ensure thread safety and proper visibility of the connection factory across threads, this field should be declared volatile.

Suggested change
private static @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB>
connectionFactory = null;
private static volatile @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB>
connectionFactory = null;

Comment on lines 528 to 533
private boolean pruned(Class<?> clazz) {
return clazz.isPrimitive()
|| clazz.isArray()
|| clazz.getCanonicalName().equals("jdk.internal.HotSpotIntrinsicCandidate")
|| EXCLUDED_NAMES.contains(clazz.getCanonicalName())
|| getPrunedPattern().matcher(clazz.getName()).matches();
}

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

Class.getCanonicalName() can return null for local or anonymous classes (or arrays thereof). While Guava's ImmutableSet.contains(null) is null-safe and returns false, relying on this behavior is implicit and could easily break if EXCLUDED_NAMES is ever refactored to a standard JDK collection (like Set.of(), which throws a NullPointerException on contains(null)). It is safer and more future-proof to explicitly check for null.

Suggested change
private boolean pruned(Class<?> clazz) {
return clazz.isPrimitive()
|| clazz.isArray()
|| clazz.getCanonicalName().equals("jdk.internal.HotSpotIntrinsicCandidate")
|| EXCLUDED_NAMES.contains(clazz.getCanonicalName())
|| getPrunedPattern().matcher(clazz.getName()).matches();
}
private boolean pruned(Class<?> clazz) {
String canonicalName = clazz.getCanonicalName();
return clazz.isPrimitive()
|| clazz.isArray()
|| (canonicalName != null && EXCLUDED_NAMES.contains(canonicalName))
|| getPrunedPattern().matcher(clazz.getName()).matches();
}

forkEvery 1
maxParallelForks 4
systemProperty "beamTestPipelineOptions", JsonOutput.toJson(preCommitBeamTestPipelineOptions)
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

This expression can be simplified and made more idiomatic by using Groovy's elvis operator directly on the result of findProperty, avoiding the redundant call to project.property.

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

forkEvery 1
maxParallelForks 4
systemProperty "beamTestPipelineOptions", JsonOutput.toJson(preCommitBeamTestPipelineOptions)
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

This expression can be simplified and made more idiomatic by using Groovy's elvis operator directly on the result of findProperty, avoiding the redundant call to project.property.

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

// run tests with Java 17 using -PtestJavaVersion=17 -Pjava17Home=???
if (project.hasProperty('testJavaVersion') &&
project.getProperty('testJavaVersion') in ['17', '21']) {
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

This expression can be simplified and made more idiomatic by using Groovy's elvis operator directly on the result of findProperty, avoiding the redundant call to project.property.

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

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
R: @liferoad for label build.
R: @Dippatel98 for label kafka.

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).

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.

[Task]: Remove powermock dependency

1 participant