From b04f05e31380edf425dd6bad407e8f6d0b2c3834 Mon Sep 17 00:00:00 2001 From: Robert Yokota Date: Tue, 14 Mar 2023 23:15:40 -0700 Subject: [PATCH] DGS-6373 Ignore leading dot when merging Protobuf custom options (#2577) --- .../kafka/schemaregistry/protobuf/ProtobufSchema.java | 2 +- .../kafka/schemaregistry/protobuf/ProtobufSchemaTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protobuf-provider/src/main/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchema.java b/protobuf-provider/src/main/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchema.java index 328572f52c8..4699a94865a 100644 --- a/protobuf-provider/src/main/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchema.java +++ b/protobuf-provider/src/main/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchema.java @@ -1132,7 +1132,7 @@ private static Map mergeOptions(List optio // which may not be using the alternative aggregate syntax. return options.stream() .collect(Collectors.toMap( - OptionElement::getName, + o -> o.getName().startsWith(".") ? o.getName().substring(1) : o.getName(), o -> o, ProtobufSchema::merge)); } diff --git a/protobuf-provider/src/test/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchemaTest.java b/protobuf-provider/src/test/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchemaTest.java index adda20d4ed9..d21bf6f2eaf 100644 --- a/protobuf-provider/src/test/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchemaTest.java +++ b/protobuf-provider/src/test/java/io/confluent/kafka/schemaregistry/protobuf/ProtobufSchemaTest.java @@ -417,7 +417,7 @@ public void testComplexCustomOptions() { + "option java_multiple_files = true;\n" + "option (com.custom.map).subject = 'user-value';\n" + "option (com.custom.map).compatibility_mode = FULL;\n" - + "option (confluent.file_meta).doc = \"file meta\";\n" + + "option (.confluent.file_meta).doc = \"file meta\";\n" + "option (confluent.file_meta).params = [\n" + " {\n" + " value: \"my_value\",\n" @@ -438,7 +438,7 @@ public void testComplexCustomOptions() { + "option java_multiple_files = true;\n" + "option (com.custom.map).subject = \"user-value\";\n" + "option (com.custom.map).compatibility_mode = FULL;\n" - + "option (confluent.file_meta).doc = \"file meta\";\n" + + "option (.confluent.file_meta).doc = \"file meta\";\n" + "option (confluent.file_meta).params = [{\n" + " value: \"my_value\",\n" + " key: \"my_key\"\n"