congbobo184 commented on a change in pull request #9612:
URL: https://github.com/apache/pulsar/pull/9612#discussion_r580754274
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
##########
@@ -293,12 +295,36 @@ private void checkCompatible(SchemaAndMetadata
existingSchema, SchemaData newSch
SchemaData schemaData) {
final CompletableFuture<SchemaVersion> completableFuture = new
CompletableFuture<>();
SchemaVersion schemaVersion;
- for (SchemaAndMetadata schemaAndMetadata : schemaAndMetadataList) {
- if
(Arrays.equals(hashFunction.hashBytes(schemaAndMetadata.schema.getData()).asBytes(),
- hashFunction.hashBytes(schemaData.getData()).asBytes())) {
- schemaVersion = schemaAndMetadata.version;
- completableFuture.complete(schemaVersion);
- return completableFuture;
+ if (isUsingAvroSchemaParser(schemaData.getType())) {
+ Schema.Parser parser = new Schema.Parser();
+ Schema newSchema = parser.parse(new String(schemaData.getData(),
UTF_8));
+
+ for (SchemaAndMetadata schemaAndMetadata : schemaAndMetadataList) {
+ if (isUsingAvroSchemaParser(schemaData.getType())) {
+ Schema.Parser existParser = new Schema.Parser();
+ Schema existSchema = existParser.parse(new
String(schemaAndMetadata.schema.getData(), UTF_8));
+ if (newSchema.equals(existSchema)) {
+ schemaVersion = schemaAndMetadata.version;
+ completableFuture.complete(schemaVersion);
+ return completableFuture;
+ }
+ } else {
+ if
(Arrays.equals(hashFunction.hashBytes(schemaAndMetadata.schema.getData()).asBytes(),
+
hashFunction.hashBytes(schemaData.getData()).asBytes())) {
+ schemaVersion = schemaAndMetadata.version;
+ completableFuture.complete(schemaVersion);
+ return completableFuture;
+ }
Review comment:
schemaType don't check now, it will be fix in another pr and
```GenericProtobufNativeSchema``` will be fix in another pr. this pr only fix
the avro comparison. :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]