Skip to content

[ErrorProne] Fix AutoValueBoxedValues warnings across the codebase#37792

Merged
kennknowles merged 5 commits intoapache:masterfrom
stankiewicz:error_prone_AutoValueBoxedValues
Mar 11, 2026
Merged

[ErrorProne] Fix AutoValueBoxedValues warnings across the codebase#37792
kennknowles merged 5 commits intoapache:masterfrom
stankiewicz:error_prone_AutoValueBoxedValues

Conversation

@stankiewicz
Copy link
Contributor

This PR resolves the AutoValueBoxedValues warnings generated by Error Prone by refactoring AutoValue instances and builders to use primitive types instead of their boxed equivalents.

Changes made:

  • Removed AutoValueBoxedValues from the disabledChecks list in the BeamModulePlugin.groovy where appropriate.
    Converted boxed properties to primitive types across AutoValue configurations in multiple SDKs and Integration Test payloads (e.g. Boolean to boolean, Integer to int, etc.).
  • Refactored relevant getter and builder methods to align with primitive parameters.
  • Addressed compatibility concerns by dropping superfluous null checks on now-primitive values.
  • Assured build and test passes via ./gradlew compileTestJava --continue.
  • Applied standard Groovy and standard Java code formatting via Spotless.

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 resolves Error Prone's AutoValueBoxedValues warnings throughout the codebase by refactoring AutoValue instances and builders to utilize primitive types instead of their boxed counterparts. This change improves code efficiency, reduces the risk of null pointer exceptions, and maintains code consistency through standard formatting.

Highlights

  • AutoValue Boxed Values: This PR addresses AutoValueBoxedValues warnings by converting boxed types (e.g., Integer, Boolean) to their primitive equivalents (e.g., int, boolean) in AutoValue classes and builders.
  • Codebase Refactoring: Refactored AutoValue instances and builders across multiple SDKs and integration tests to use primitive types, enhancing code efficiency and reducing potential null pointer exceptions.
  • Compatibility and Formatting: Ensured compatibility by removing unnecessary null checks and applied standard Groovy and Java code formatting using Spotless.

🧠 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
    • Removed AutoValueBoxedValues from the disabled checks list.
    • Added -Xep:AutoValueBoxedValues:WARN to errorproneArgs to enable the warning.
  • examples/java/src/main/java/org/apache/beam/examples/complete/datatokenization/utils/CsvConverters.java
    • Converted hasHeaders property from Boolean to boolean.
    • Updated builder method setHasHeaders to accept a boolean.
    • Removed null check for hasHeaders in the build method.
  • it/clickhouse/src/main/java/org/apache/beam/it/clickhouse/conditions/ClickHouseRowsCheck.java
    • Changed minRows property from Integer to int.
    • Updated builder method setMinRows to accept an int.
  • it/datadog/src/main/java/org/apache/beam/beam/it/datadog/conditions/DatadogLogEntriesCheck.java
    • Modified minEntries property from Integer to int.
    • Updated builder method setMinEntries to accept an int.
  • it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigquery/conditions/BigQueryRowsCheck.java
    • Changed minRows property from Integer to int.
    • Updated builder method setMinRows to accept an int.
  • it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/pubsub/conditions/PubsubMessagesCheck.java
    • Modified minMessages property from Integer to int.
    • Updated builder method setMinMessages to accept an int.
  • it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigquery/BigQueryStreamingLT.java
    • Converted getMinutes, getByteSizePerField, getNumFields, and getRowsPerSecond properties from Integer to int.
  • it/google-cloud-platform/src/test/java/org/apache/beam/it/gcp/bigtable/BigTableIOLT.java
    • Changed getNumRows property from Long to long.
    • Modified getPipelineTimeout and getValueSizeBytes properties from Integer to int.
  • it/kafka/src/test/java/org/apache/beam/it/kafka/KafkaIOLT.java
    • Converted getNumRows property from Long to long.
    • Modified getPipelineTimeout and getRowSize properties from Integer to int.
  • it/mongodb/src/main/java/org/apache/beam/it/mongodb/conditions/MongoDBDocumentsCheck.java
    • Changed minDocuments property from Integer to int.
    • Updated builder method setMinDocuments to accept an int.
  • it/splunk/src/main/java/org/apache/beam/it/splunk/conditions/SplunkEventsCheck.java
    • Modified minEvents property from Integer to int.
    • Updated builder method setMinEvents to accept an int.
  • runners/java-fn-execution/src/test/java/org/apache/beam/runners/fnexecution/wire/CommonCoderTest.java
    • Changed getNonDeterministic property from Boolean to boolean.
  • sdks/java/core/src/main/java/org/apache/beam/sdk/providers/GenerateSequenceSchemaTransformProvider.java
    • Removed unnecessary import of checkNotNull.
    • Converted getElements and getStart properties from Long to long.
    • Updated builder methods setElements and setStart to accept long.
    • Removed null check for start in the validate method.
  • sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/Schema.java
    • Changed getNullable property from Boolean to boolean.
    • Updated builder method setNullable to accept a boolean.
    • Updated equals and typesEqual methods to directly compare boolean values instead of using Objects.equals.
  • sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/Group.java
    • Changed getFewKeys property from Boolean to boolean.
    • Updated builder method setFewKeys to accept a boolean.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/AutoValueSchemaTest.java
    • Converted getLng property from Long to long in SchemaFieldNumberSimpleClass and SchemaFieldDescriptionSimpleClass.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/SchemaCoderTest.java
    • Modified getInt32 and getInt64 properties from Integer and Long to int and long in SimpleAutoValue.
    • Updated SimpleAutoValue.of method to accept int and long.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/transforms/SelectTest.java
    • Changed getField2 and getField3 properties from Integer and Double to int and double in Schema1.
    • Modified getField3 property from Double to double in Schema1Selected and Schema1SelectedRenamed.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/transforms/TypedSchemaTransformProviderTest.java
    • Changed getIntegerField property from Integer to int in Configuration.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoSchemaTest.java
    • Modified getIntegerField property from Integer to int in Inferred, Inferred2, and ForExtraction.
  • sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ToJsonTest.java
    • Changed getHeight and getKnowsJavascript properties from Integer and Boolean to int and boolean in Person.
    • Updated Person.of method to accept int and boolean.
  • sdks/java/expansion-service/src/test/java/org/apache/beam/sdk/expansion/service/ExpansionServiceTest.java
    • Converted getFoo property from Long to long in TestConfigSimpleSchema.
  • sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java
    • Updated genericFromBeamField method to directly compare boolean values.
  • sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPDeidentifyText.java
    • Modified getBatchSizeBytes property from Integer to int.
    • Updated builder method setBatchSizeBytes to accept an int.
  • sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPInspectText.java
    • Modified getBatchSizeBytes property from Integer to int.
    • Updated builder method setBatchSizeBytes to accept an int.
  • sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/DLPReidentifyText.java
    • Modified getBatchSizeBytes property from Integer to int.
    • Updated builder method setBatchSizeBytes to accept an int.
  • sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/RecommendationAIImportCatalogItems.java
    • Modified batchSize property from Integer to int.
    • Updated withBatchSize method and builder method setBatchSize to accept an int.
  • sdks/java/extensions/ml/src/main/java/org/apache/beam/sdk/extensions/ml/RecommendationAIImportUserEvents.java
    • Modified batchSize property from Integer to int.
    • Updated withBatchSize method and builder method setBatchSize to accept an int.
  • sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlAlterTable.java
    • Updated unparseColumn method to directly check boolean value instead of using Objects.equals.
  • sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlCreateExternalTable.java
    • Updated unparseColumn method to directly check boolean value instead of using Objects.equals.
  • sdks/java/extensions/timeseries/src/main/java/org/apache/beam/sdk/extensions/timeseries/FillGaps.java
    • Converted getMaxGapFillBuckets property from Long to long.
    • Updated builder method setMaxGapFillBuckets and withMaxGapFillBuckets method to accept a long.
  • sdks/java/extensions/zetasketch/src/main/java/org/apache/beam/sdk/extensions/zetasketch/ApproximateCountDistinct.java
    • Modified getPrecision property from Integer to int.
    • Updated withPercision methods and builder method setPrecision to accept an int.
  • sdks/java/io/amazon-web-services2/src/test/java/org/apache/beam/sdk/io/aws2/dynamodb/testing/DynamoDBIOIT.java
    • Updated buildWriteRequest method to convert row.id() to a string using String.valueOf().
  • sdks/java/io/amazon-web-services2/src/test/java/org/apache/beam/sdk/io/aws2/kinesis/KinesisIOWriteTest.java
    • Updated withPartitioner method to convert row.id() to a string using String.valueOf().
  • sdks/java/io/cdap/src/test/java/org/apache/beam/sdk/io/cdap/TestRowDBWritable.java
    • Modified id property from Integer to int.
  • sdks/java/io/common/src/main/java/org/apache/beam/sdk/io/common/SchemaAwareJavaBeans.java
    • Modified allPrimitiveDataTypes method to accept primitive types.
    • Modified byteType method to accept primitive type.
    • Modified AllPrimitiveDataTypes class to use primitive types.
    • Modified ByteType class to use primitive type.
  • sdks/java/io/common/src/main/java/org/apache/beam/sdk/io/common/TestRow.java
    • Modified id property from Integer to int.
    • Updated create and fromSeed methods to accept int.
    • Updated compareTo method to use Integer.compare.
  • sdks/java/io/datadog/src/main/java/org/apache/beam/sdk/io/datadog/DatadogEventPublisher.java
    • Modified maxElapsedMillis property from Integer to int.
    • Updated builder method setMaxElapsedMillis to accept an int.
  • sdks/java/io/debezium/src/main/java/org/apache/beam/sdk/io/debezium/DebeziumReadSchemaTransformProvider.java
    • Modified getPort property from Integer to int.
    • Updated builder method setPort to accept an int.
  • sdks/java/io/elasticsearch/src/main/java/org/apache/beam/sdk/io/elasticsearch/ElasticsearchIO.java
    • Changed getHasError from Boolean to boolean.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java
    • Changed getWithTemplateCompatibility and getUseAvroLogicalTypes properties from Boolean to boolean.
    • Updated builder methods setWithTemplateCompatibility and setUseAvroLogicalTypes to accept a boolean.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOTranslation.java
    • Removed null checks for boolean properties.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/WritePartition.java
    • Changed isFirstPane from Boolean to boolean.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/WriteTables.java
    • Changed isFirstPane from Boolean to boolean.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerIO.java
    • Changed getBatching from Boolean to boolean.
    • Updated builder method setBatching to accept a boolean.
  • sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/BigqueryMatcher.java
    • Changed getUsingStandardSql from Boolean to boolean.
    • Updated createQuery method to accept a boolean.
  • sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIOTest.java
    • Changed Boolean properties to boolean in FailureOptions.
  • sdks/java/io/hadoop-format/src/test/java/org/apache/beam/sdk/io/hadoop/format/TestRowDBWritable.java
    • Modified id from Integer to int.
  • sdks/java/io/hbase/src/test/java/org/apache/beam/sdk/io/hbase/HBaseIOIT.java
    • Updated ConstructMutations DoFn to convert row.id() to a string.
  • sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java
    • Changed getReturnResults from Boolean to boolean.
  • sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaSourceDescriptor.java
    • Modified getPartition from Integer to int.
    • Updated create method to accept an int.
  • sdks/java/io/rrio/src/main/java/org/apache/beam/sdk/io/requestresponse/Call.java
    • Changed getShouldRepeat from Boolean to boolean.
  • sdks/java/io/rrio/src/main/java/org/apache/beam/sdk/io/requestresponse/Monitoring.java
    • Changed all getCount... properties from Boolean to boolean.
  • sdks/java/io/rrio/src/test/java/org/apache/beam/sdk/io/requestresponse/RequestResponseIOTest.java
    • Modified getALong from Long to long in Request and Response.
  • sdks/java/io/singlestore/src/test/java/org/apache/beam/sdk/io/singlestore/TestHelper.java
    • Updated TestUserDataMapper to convert element.id() to a string.
  • sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/data/Solace.java
    • Changed getPublished from Boolean to boolean.
  • sdks/java/io/splunk/src/main/java/org/apache/beam/sdk/io/splunk/HttpEventPublisher.java
    • Changed disableCertificateValidation and enableGzipHttpCompression to be nullable.
  • sdks/java/managed/src/main/java/org/apache/beam/sdk/managed/testing/TestSchemaTransformProvider.java
    • Modified getExtraInteger property from Integer to int.
Activity
  • The PR author, stankiewicz, has refactored AutoValue instances and builders to use primitive types instead of their boxed equivalents.
  • Compatibility concerns were addressed by dropping superfluous null checks on now-primitive values.
  • Standard Groovy and standard Java code formatting was applied via Spotless.
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.

@stankiewicz stankiewicz marked this pull request as draft March 6, 2026 20:23
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.

As long as this doesn't change semantics in problematic ways, this is fine.

A couple cases where it could be a problem:

  • There is no default and the field is required, so it must be provided or set before calling build(). What happens? Will autovalue (incorrectly) set it to Java's default value?
  • Some field is actually meant to be nullable but we wrote the class wrong and suppressed warnings. Then we will end up having to change it back.

But the overall change I am fine with, basically. Just need to make sure it isn't breaking things.


abstract Optional<Boolean> getCountResponses();

abstract Optional<Boolean> getCountCalls();
Copy link
Member

Choose a reason for hiding this comment

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

This one looks like it needs to be a @Nullable Boolean. Clearly there is an intention that it could have three states: absent, true, or false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, it's required. they validate value and on built() they set it to false if there is no value so in the end it's two states.

@stankiewicz stankiewicz force-pushed the error_prone_AutoValueBoxedValues branch from 2a95aa1 to 21089cd Compare March 10, 2026 13:14
@stankiewicz stankiewicz force-pushed the error_prone_AutoValueBoxedValues branch from 21089cd to 1d28eab Compare March 10, 2026 14:27
@stankiewicz stankiewicz marked this pull request as ready for review March 10, 2026 14:31
@stankiewicz stankiewicz force-pushed the error_prone_AutoValueBoxedValues branch from 1d28eab to 5a0728d Compare March 10, 2026 14:32
@stankiewicz
Copy link
Contributor Author

/gemini review

@github-actions
Copy link
Contributor

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

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 is a large but valuable refactoring to address AutoValueBoxedValues warnings from Error Prone, replacing boxed types with their primitive equivalents across AutoValue classes. This results in cleaner and more efficient code, handling necessary follow-up changes like removing redundant null checks and updating method signatures. A comprehensive security audit found no new security vulnerabilities introduced by these changes. However, I've identified a critical issue in DatadogEventPublisher.java where a checkNotNull call on a new primitive int parameter will cause a compilation failure. Additionally, a couple of minor pre-existing typos could be addressed.

@stankiewicz
Copy link
Contributor Author

Run Portable_Python PreCommit 3.10

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.

Got it - I like how you have refactored where defaults are set.

@kennknowles kennknowles merged commit 9829d6d into apache:master Mar 11, 2026
47 of 52 checks passed
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