Bump CI Java version to Java21#39205
Conversation
|
list of failing tests in precommit: |
419ac96 to
406c5a2
Compare
Summary of ChangesHello, 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
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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| private static @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB> | ||
| connectionFactory = null; |
There was a problem hiding this comment.
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.
| private static @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB> | |
| connectionFactory = null; | |
| private static volatile @Nullable BiFunction<DataSourceConfiguration, Boolean, InfluxDB> | |
| connectionFactory = null; |
| 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(); | ||
| } |
There was a problem hiding this comment.
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.
| 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() |
There was a problem hiding this comment.
| forkEvery 1 | ||
| maxParallelForks 4 | ||
| systemProperty "beamTestPipelineOptions", JsonOutput.toJson(preCommitBeamTestPipelineOptions) | ||
| def testJavaVer = project.findProperty('testJavaVersion') ? (project.property('testJavaVersion') as int) : JavaVersion.current().majorVersion.toInteger() |
There was a problem hiding this comment.
| // 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() |
There was a problem hiding this comment.
|
Assigning reviewers: R: @kennknowles for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
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:
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, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.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)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.