[
https://issues.apache.org/jira/browse/BEAM-11530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Filip Krakowski updated BEAM-11530:
-----------------------------------
Description:
I'm facing an exception telling me that my JavaBean contained a setter for a
field that had a mismatching nullable attribute, although both getter and
setter (parameters) are annotated with @Nullable.
The code responsible for determining if a setter's parameter is nullable looks
wrong to me, since it does check if the type (class) itself is annotated with
@Nullable instead of checking the actual parameter's annotations.
[FieldValueTypeInformation|https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java#L234-L236]
{code:java}
boolean nullable =
Arrays.stream(method.getParameters()[0].getAnnotatedType().getAnnotations())
.anyMatch(annotation -> isNullableAnnotation(annotation));{code}
In my understanding this should look like this.
{code:java}
boolean nullable =
Arrays.stream(method.getParameters()[0].getAnnotations())
.anyMatch(FieldValueTypeInformation::isNullableAnnotation);{code}
was:
I'm facing an exception telling me that my JavaBean contained a setter for a
field that had a mismatching nullable attribute, although both getter and
setter (parameters) are annotated with @Nullable.
The code responsible for determining if a setter's parameter is nullable looks
wrong to me, since it does check if the type (class) itself is annotated with
@Nullable instead of checking the actual parameter's annotations. java.lang.Long
[FieldValueTypeInformation|https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java#L234-L236]
{code:java}
boolean nullable =
Arrays.stream(method.getParameters()[0].getAnnotatedType().getAnnotations())
.anyMatch(annotation -> isNullableAnnotation(annotation));{code}
In my understanding this should look like this.
{code:java}
boolean nullable =
Arrays.stream(method.getParameters()[0].getAnnotations())
.anyMatch(FieldValueTypeInformation::isNullableAnnotation);{code}
> Annotated setter parameters handled wrong in schema creation
> ------------------------------------------------------------
>
> Key: BEAM-11530
> URL: https://issues.apache.org/jira/browse/BEAM-11530
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Affects Versions: 2.26.0
> Environment: Linux & OpenJDK 15
> Reporter: Filip Krakowski
> Priority: P0
> Labels: annotation, fieldtype, parameter, schema
>
> I'm facing an exception telling me that my JavaBean contained a setter for a
> field that had a mismatching nullable attribute, although both getter and
> setter (parameters) are annotated with @Nullable.
>
> The code responsible for determining if a setter's parameter is nullable
> looks wrong to me, since it does check if the type (class) itself is
> annotated with @Nullable instead of checking the actual parameter's
> annotations.
>
> [FieldValueTypeInformation|https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FieldValueTypeInformation.java#L234-L236]
> {code:java}
> boolean nullable =
> Arrays.stream(method.getParameters()[0].getAnnotatedType().getAnnotations())
> .anyMatch(annotation -> isNullableAnnotation(annotation));{code}
>
> In my understanding this should look like this.
> {code:java}
> boolean nullable =
> Arrays.stream(method.getParameters()[0].getAnnotations())
> .anyMatch(FieldValueTypeInformation::isNullableAnnotation);{code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)