Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
[fix][client] GenericProtobufNativeSchema not implement getNativeSche…
Browse files Browse the repository at this point in the history
…ma method. (apache#22204)
  • Loading branch information
shibd authored Mar 6, 2024
1 parent 4ff8600 commit e84516f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand Down Expand Up @@ -68,6 +69,11 @@ public Descriptors.Descriptor getProtobufNativeSchema() {
return descriptor;
}

@Override
public Optional<Object> getNativeSchema() {
return Optional.of(descriptor);
}

@Override
public boolean supportSchemaVersioning() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,7 @@
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

@Slf4j
public class GenericProtobufNativeReaderTest {
Expand Down Expand Up @@ -79,6 +81,12 @@ public void testGetNativeRecord() {
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;

Expand Down

0 comments on commit e84516f

Please sign in to comment.