[
https://issues.apache.org/jira/browse/BEAM-6277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16726098#comment-16726098
]
Kenneth Knowles commented on BEAM-6277:
---------------------------------------
The annotations on {{getKey}} and {{getValue}} are actually correct. I am not
sure if the various pluggable type system implementations do it right though.
{{KV<KeyT, ValueT>}} can be instantiated with any type for {{KeyT}} and
{{ValueT}}. Specifically, since Java 8, you can have {{KeyT := @Nullable
SomeKeyType}} and {{ValueT := SomeValueType}}. So the resulting type is
{{KV<@Nullable SomeKeyType, @Nullable SomeValueType>}}. The nullability is a
property of the key or value type, not of {{KV}} itself. This is important:
{{KV}} never causes nullability.
The annotations on {{of}} are not correct. It should just accept a {{KeyT}} and
{{ValueT}} and whether or not {{null}} is a member of those types should not be
visible to {{KV}}.
Leaving this bug open to fix the annotations on {{of}}, if our analyzers will
let us. (I think findbugs is not updated for this)
> KV#getValue is not marked with @Nullable, even though it can be null.
> ---------------------------------------------------------------------
>
> Key: BEAM-6277
> URL: https://issues.apache.org/jira/browse/BEAM-6277
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-core
> Affects Versions: 2.8.0, 2.9.0
> Reporter: Jan Callewaert
> Assignee: Kenneth Knowles
> Priority: Minor
>
> On {{KV#getKey}}, there is the annotation {{@Nullable}}. That annotation is
> missing on {{KV#getValue}}, so I would assume that this means the value
> cannot be null. However, in {{KV#of}}, the parameter {{value}} is annotated
> with {{@Nullable}} and no further {{null}} checks are done.
> I would assume that {{KV#getValue}} should also be marked with {{@Nullable}},
> or that the annotation {{@Nullable}} on the parameter {{value}} in the
> constructor and in {{KV#of}} should be removed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)