From 294456a9ebb4937c617633ff04a68044b09bec3b Mon Sep 17 00:00:00 2001 From: nitinware Date: Mon, 7 Sep 2026 10:44:31 -0500 Subject: [PATCH] Remove nullness suppression in TaggedPValue Iterables.getOnlyElement returns @Nullable T in the Checker Framework stubs; the "nullness" and "keyfor" suppression on ofExpandedValue can be replaced with an explicit Preconditions.checkArgumentNotNull at the call site. Progress on #20507. --- .../main/java/org/apache/beam/sdk/values/TaggedPValue.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/TaggedPValue.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/TaggedPValue.java index ded5bef31131..bfd08202114d 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/values/TaggedPValue.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/values/TaggedPValue.java @@ -19,6 +19,7 @@ import com.google.auto.value.AutoValue; import org.apache.beam.sdk.annotations.Internal; +import org.apache.beam.sdk.util.Preconditions; import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.Iterables; /** @@ -33,9 +34,10 @@ public static TaggedPValue of(TupleTag tag, PCollection value) { return new AutoValue_TaggedPValue(tag, value); } - @SuppressWarnings({"keyfor", "nullness"}) public static TaggedPValue ofExpandedValue(PCollection value) { - return of(Iterables.getOnlyElement(value.expand().keySet()), value); + return of( + Preconditions.checkArgumentNotNull(Iterables.getOnlyElement(value.expand().keySet())), + value); } /** Returns the local tag associated with the {@link PValue}. */