From 7113db52ca92ab0f47417bd822fb6c7e36313973 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 13 Nov 2024 16:30:33 -0500 Subject: [PATCH] Make AvroUtils compatible with older versions of Avro (#33102) (#33105) * Make AvroUtils compatible with older versions of Avro * Create beam_PostCommit_Java_Avro_Versions.json * Update AvroUtils.java * Fix nullness --- .../trigger_files/beam_PostCommit_Java_Avro_Versions.json | 4 ++++ .../beam/sdk/extensions/avro/schemas/utils/AvroUtils.java | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .github/trigger_files/beam_PostCommit_Java_Avro_Versions.json diff --git a/.github/trigger_files/beam_PostCommit_Java_Avro_Versions.json b/.github/trigger_files/beam_PostCommit_Java_Avro_Versions.json new file mode 100644 index 000000000000..1efc8e9e4405 --- /dev/null +++ b/.github/trigger_files/beam_PostCommit_Java_Avro_Versions.json @@ -0,0 +1,4 @@ +{ + "comment": "Modify this file in a trivial way to cause this test suite to run", + "modification": 1 +} diff --git a/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java b/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java index bfbab6fe87f6..da7daf605d89 100644 --- a/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java +++ b/sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java @@ -141,7 +141,10 @@ * * is used. */ -@SuppressWarnings({"rawtypes"}) +@SuppressWarnings({ + "nullness", // TODO(https://github.com/apache/beam/issues/20497) + "rawtypes" +}) public class AvroUtils { private static final ForLoadedType BYTES = new ForLoadedType(byte[].class); private static final ForLoadedType JAVA_INSTANT = new ForLoadedType(java.time.Instant.class); @@ -484,7 +487,8 @@ public static Field toBeamField(org.apache.avro.Schema.Field field) { public static org.apache.avro.Schema.Field toAvroField(Field field, String namespace) { org.apache.avro.Schema fieldSchema = getFieldSchema(field.getType(), field.getName(), namespace); - return new org.apache.avro.Schema.Field(field.getName(), fieldSchema, field.getDescription()); + return new org.apache.avro.Schema.Field( + field.getName(), fieldSchema, field.getDescription(), (Object) null); } private AvroUtils() {}