You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2024/03/13 05:00:20 UTC
(pulsar) branch branch-3.2 updated: [fix][client] GenericProtobufNativeSchema not implement getNativeSchema method. (#22204)
This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.2 by this push:
new 0b2ab7a9f40 [fix][client] GenericProtobufNativeSchema not implement getNativeSchema method. (#22204)
0b2ab7a9f40 is described below
commit 0b2ab7a9f409bd0342d3156aedcfaf731d779a89
Author: Baodi Shi <ba...@apache.org>
AuthorDate: Thu Mar 7 07:28:51 2024 +0800
[fix][client] GenericProtobufNativeSchema not implement getNativeSchema method. (#22204)
---
.../client/impl/schema/generic/GenericProtobufNativeSchema.java | 6 ++++++
.../impl/schema/generic/GenericProtobufNativeReaderTest.java | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeSchema.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeSchema.java
index 4ae2a21929a..62a36fee351 100644
--- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeSchema.java
+++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeSchema.java
@@ -20,6 +20,7 @@ package org.apache.pulsar.client.impl.schema.generic;
import static org.apache.pulsar.client.impl.schema.generic.MultiVersionGenericProtobufNativeReader.parseProtobufSchema;
import com.google.protobuf.Descriptors;
+import java.util.Optional;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.schema.Field;
@@ -68,6 +69,11 @@ public class GenericProtobufNativeSchema extends AbstractGenericSchema {
return descriptor;
}
+ @Override
+ public Optional<Object> getNativeSchema() {
+ return Optional.of(descriptor);
+ }
+
@Override
public boolean supportSchemaVersioning() {
return true;
diff --git a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReaderTest.java b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReaderTest.java
index 4cbb325c82f..c358f30ccae 100644
--- a/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReaderTest.java
+++ b/pulsar-client/src/test/java/org/apache/pulsar/client/impl/schema/generic/GenericProtobufNativeReaderTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.pulsar.client.impl.schema.generic;
+import com.google.protobuf.Descriptors;
import com.google.protobuf.DynamicMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.schema.GenericRecord;
@@ -29,6 +30,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
@Slf4j
public class GenericProtobufNativeReaderTest {
@@ -79,6 +81,12 @@ public class GenericProtobufNativeReaderTest {
assertEquals(nativeRecord.getField(nativeRecord.getDescriptorForType().findFieldByName("doubleField")), DOUBLE_FIELD_VLUE);
}
+ @Test
+ public void testGetNativeSchema() {
+ assertTrue(genericProtobufNativeSchema.getNativeSchema().isPresent());
+ assertTrue(genericProtobufNativeSchema.getNativeSchema().get() instanceof Descriptors.Descriptor);
+ }
+
private static final String STRING_FIELD_VLUE = "stringFieldValue";
private static final double DOUBLE_FIELD_VLUE = 0.2D;