Skip to content

Conversation

@copybara-service
Copy link
Contributor

Fix an issue with builder getters.

In a builder, if a property bar has its own builder barBuilder() and also a getter bar(), then either the property must be set or barBuilder() must be called.
If neither of those has happened, both the bar and barBuilder$ fields will be null, and we should correctly report that with an empty Optional return from bar().
Previously we incorrectly simplified this logic and ended up calling Optional.of(bar) even though bar is null.

Fixes #1386. Thanks to @jmesny for the bug report and regression test.

RELNOTES=Fixed an issue when a builder has a property foo with both a getter foo() and a builder fooBuilder().

@copybara-service copybara-service bot force-pushed the test_483480779 branch 2 times, most recently from 259e2a0 to 4c2328d Compare October 25, 2022 18:42
In a builder, if a property `bar` has its own builder `barBuilder()` and also a getter `bar()`, then either the property must be set or `barBuilder()` must be called.
If neither of those has happened, both the `bar` and `barBuilder$` fields will be null, and we should correctly report that with an empty `Optional` return from `bar()`.
Previously we incorrectly simplified this logic and ended up calling `Optional.of(bar)` even though `bar` is null.

Fixes #1386. Thanks to @jmesny for the bug report and regression test.

RELNOTES=Fixed an issue when a builder has a property `foo` with both a getter `foo()` and a builder `fooBuilder()`.
PiperOrigin-RevId: 483736037
@copybara-service copybara-service bot merged commit 3659a0e into master Oct 25, 2022
@copybara-service copybara-service bot deleted the test_483480779 branch October 25, 2022 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AutoValue] NPE since v1.10 when using builder getters and nested builders

2 participants