codelipenghui commented on a change in pull request #5227: [PIP-44] Separate 
schema compatibility checker for producer and consumer
URL: https://github.com/apache/pulsar/pull/5227#discussion_r333435722
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
 ##########
 @@ -245,6 +240,28 @@ private void checkCompatible(SchemaAndMetadata 
existingSchema, SchemaData newSch
         });
     }
 
+    @Override
+    public CompletableFuture<Void> checkConsumerCompatibility(String schemaId, 
SchemaData schemaData,
+                                                              
SchemaCompatibilityStrategy strategy) {
+        return getSchema(schemaId).thenCompose(existingSchema -> {
+            if (existingSchema != null && !existingSchema.schema.isDeleted()) {
+                    if (strategy == SchemaCompatibilityStrategy.BACKWARD ||
+                            strategy == SchemaCompatibilityStrategy.FORWARD ||
+                            strategy == 
SchemaCompatibilityStrategy.FORWARD_TRANSITIVE ||
+                            strategy == SchemaCompatibilityStrategy.FULL) {
+                        return checkCompatibilityWithLatest(schemaId, 
schemaData, SchemaCompatibilityStrategy.BACKWARD);
+                    } else {
+                        return checkCompatibilityWithAll(schemaId, schemaData, 
strategy);
+                    }
+            } else {
+                return FutureUtil.failedFuture(
+                        new IncompatibleSchemaException(
+                                "Trying to subscribe with incompatible schema"
+                        ));
 
 Review comment:
   Shall we need to check the schema is exist, i think this can be handle in  
checkCompatibilityWithLatest and checkCompatibilityWithAll ?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to