You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the nested builder from Bar is exposed, the generated bar() builder getter in Foo does not work as expected.
The reason is that the generated implementation does not handle the case where the bar value would be missing, as stated by the Optional return type.
Calling this bar() method would lead to a NullPointerException being thrown.
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: 483480779
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: 483480779
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: 483480779
Hi,
Since version 1.10 it is no longer possible to use builder getters and nested builders at the same time.
Here is an example describing the issue.
When the nested builder from
Bar
is exposed, the generatedbar()
builder getter inFoo
does not work as expected.The reason is that the generated implementation does not handle the case where the
bar
value would be missing, as stated by theOptional
return type.Calling this
bar()
method would lead to aNullPointerException
being thrown.The code below works with version 1.9.
Thank you!
The text was updated successfully, but these errors were encountered: