This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 71302480e63 [fix][client] GenericProtobufNativeSchema not implement
getNativeSchema method. (#22204)
71302480e63 is described below
commit 71302480e63a80ff2f731520c8542be69313fa9c
Author: Baodi Shi <[email protected]>
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;