beam icon indicating copy to clipboard operation
beam copied to clipboard

PipelineOptions getters can produce null even if not annotated Nullable when no Default is specified

Open damccorm opened this issue 3 years ago • 3 comments

Context: BEAM-13537, https://github.com/apache/beam/pull/16625#discussion_r793021931

PipelineOptions getters without Default specified can produce null, but because it happens in generated code, the null checker will not complain about it. Is there some way we can make sure getters without a Default are always Nullable?

Imported from Jira BEAM-13758. Original Jira may contain additional context. Reported by: bhulette.

damccorm avatar Jun 04 '22 22:06 damccorm

.take-issue

mga44 avatar Jul 17 '23 05:07 mga44

There seems to be no simple way to ensure that getters without the @Default annotation wouldn't produce null.

From my understanding, the best way to approach this issue would be to manually add either @Required or @Nullable annotations to unannotated getters in existing PipelineOptions implementations to warn potential users or raise exceptions during validation. Annotating getters in custom PipelineOptions implementations would be the responsibility of users.

mga44 avatar Sep 01 '23 20:09 mga44

.take-issue

viru0909-dev avatar Dec 01 '25 20:12 viru0909-dev