Skip to content

[ErrorProne] Enable EmptyCatch Error Prone check and document ignored exceptions#37754

Open
stankiewicz wants to merge 2 commits intoapache:masterfrom
stankiewicz:error_prone_emptyCatch
Open

[ErrorProne] Enable EmptyCatch Error Prone check and document ignored exceptions#37754
stankiewicz wants to merge 2 commits intoapache:masterfrom
stankiewicz:error_prone_emptyCatch

Conversation

@stankiewicz
Copy link
Contributor

This PR enables the EmptyCatch Error Prone check and addresses the resulting warnings across the codebase. Empty catch blocks that intentionally ignore exceptions are now documented with clarifying comments.

Changes Included

  • Error Prone configuration: Removed EmptyCatch from the disabled checks in BeamModulePlugin.groovy, effectively enabling it for future compilations.
  • Addressed empty catch warnings: Added explanatory comments inside previously empty catch blocks to clarify the intent of ignoring the caught exceptions (e.g., ignoring parsing exceptions to fallback to defaults, swallowing exceptions on teardown).

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.

@gemini-code-assist
Copy link
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 significantly enhances code quality and clarity by activating the 'EmptyCatch' Error Prone check. This change ensures that any intentionally ignored exceptions are now accompanied by explanatory comments, making the rationale behind such decisions transparent to developers and static analysis tools. The modifications primarily involve adding these clarifying comments to existing catch blocks that were previously empty, alongside the configuration update to enable the check.

Highlights

  • Error Prone Configuration: The 'EmptyCatch' Error Prone check has been enabled, enforcing that all empty catch blocks must now be explicitly justified.
  • Code Clarity: Previously empty catch blocks across the codebase have been updated with comments to clearly document the intent behind ignoring specific exceptions, improving code readability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory 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.

Changelog
  • buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
    • Enabled the EmptyCatch Error Prone check by removing it from the disabled list.
  • examples/java/twitter/src/main/java/org/apache/beam/examples/twitterstreamgenerator/TwitterConnection.java
    • Documented ignored exceptions during enqueueing in a catch block.
  • runners/flink/src/main/java/org/apache/beam/runners/flink/metrics/MetricsAccumulator.java
    • Documented ignored CloneNotSupportedException in a catch block.
  • runners/prism/java/src/main/java/org/apache/beam/runners/prism/PrismExecutor.java
    • Documented ignored InterruptedException during shutdown in catch blocks.
  • sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GceMetadataUtil.java
    • Added debug logging for ignored IOException when fetching GCE metadata.
  • sdks/java/io/amazon-web-services2/src/test/java/org/apache/beam/sdk/io/aws2/common/AsyncBatchWriteHandlerTest.java
    • Documented ignored AssertionError or InterruptedException during retry logic.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/changestreams/dao/DaoFactory.java
    • Documented ignored exceptions during resource closure in a catch block.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java
    • Documented ignored parsing exceptions in a catch block to allow default return.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsub.java
    • Documented ignored InterruptedException during polling in a catch block.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/TestPubsubSignal.java
    • Documented ignored InterruptedException during polling in a catch block.
  • sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/FilterUtils.java
    • Documented ignored DateTimeParseException when trying different formatters.
  • sdks/java/io/rrio/src/main/java/org/apache/beam/io/requestresponse/Call.java
    • Documented ignored InterruptedException during teardown and backoff in catch blocks.
  • sdks/java/io/rrio/src/main/java/org/apache/beam/io/requestresponse/Repeater.java
    • Documented ignored InterruptedException during retry logic in a catch block.
  • sdks/java/io/rrio/src/test/java/org/apache/beam/io/requestresponse/EchoGRPCCallerWithSetupTeardown.java
    • Documented ignored InterruptedException during gRPC channel shutdown.
Activity
  • No human activity (comments, reviews) has occurred on this pull request yet.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@stankiewicz stankiewicz changed the title Refactor: Enable EmptyCatch Error Prone check and document ignored exceptions [ErrorProne] Enable EmptyCatch Error Prone check and document ignored exceptions Mar 4, 2026
@stankiewicz
Copy link
Contributor Author

/gemini review

@stankiewicz
Copy link
Contributor Author

assign set of reviewers

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Assigning reviewers:

R: @kennknowles for label java.
R: @liferoad for label build.
R: @igorbernstein2 for label bigtable.

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

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 enables the EmptyCatch ErrorProne check and adds comments or logging to previously empty catch blocks. The changes are mostly good, adding necessary documentation for intentionally ignored exceptions. However, in a few places, exceptions are silently ignored where logging them would be more appropriate for debugging purposes. I've added suggestions to log these exceptions, which will improve observability without changing the program's control flow.

@kennknowles kennknowles self-requested a review March 5, 2026 16:22
Copy link
Member

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

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

So, on the one hand this keep all behavior the same and enables the check. On the other hand... it leaves all the problems the check is meant to prevent. Overall, LGTM since the value of turning on the check is worthwhile. It would be better if the comments explain why ignoring the exception is the right thing to do.

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.

2 participants