From 8a48d6c3b623807ec734088145f6aea8a75d7a88 Mon Sep 17 00:00:00 2001 From: Michel Davit Date: Wed, 20 Nov 2024 15:43:08 +0100 Subject: [PATCH] Add OptionlCoder to common types --- .../main/java/org/apache/beam/sdk/coders/CoderRegistry.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java index df64789ac3d2..2cf79a723d63 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; import org.apache.beam.sdk.annotations.Internal; @@ -113,6 +114,8 @@ private CommonTypes() { Instant.class, CoderProviders.fromStaticMethods(Instant.class, InstantCoder.class)); builder.put( Integer.class, CoderProviders.fromStaticMethods(Integer.class, VarIntCoder.class)); + builder.put( + Optional.class, CoderProviders.fromStaticMethods(Optional.class, OptionalCoder.class)); builder.put( Iterable.class, CoderProviders.fromStaticMethods(Iterable.class, IterableCoder.class)); builder.put(KV.class, CoderProviders.fromStaticMethods(KV.class, KvCoder.class));