This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new c952b6b  Modify the logical for getting schema compatibility strategy 
(#5785)
c952b6b is described below

commit c952b6b59ebc5f3e156de916ee9f2f88aa86732c
Author: congbo <39078850+congbobo...@users.noreply.github.com>
AuthorDate: Wed Dec 4 01:39:02 2019 +0800

    Modify the logical for getting schema compatibility strategy (#5785)
    
    ### Motivation
    Modify the logical for getting schema compatibility strategy, if 
schemaCompatibilityStrategy = SchemaCompatibilityStrategy.UNDEFINED return the 
SchemaAutoUpdateCompatibilityStrategy.
    
    ### Verifying this change
    Add the tests for it
---
 .../java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java  | 8 +++++++-
 .../pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java | 4 ++++
 .../src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java  | 4 ++--
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
index 85d043f..adc7bd4 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
@@ -2044,7 +2044,13 @@ public abstract class NamespacesBase extends 
AdminResource {
 
     protected SchemaCompatibilityStrategy 
internalGetSchemaCompatibilityStrategy() {
         validateAdminAccessForTenant(namespaceName.getTenant());
-        return 
getNamespacePolicies(namespaceName).schema_compatibility_strategy;
+        Policies policies = getNamespacePolicies(namespaceName);
+        SchemaCompatibilityStrategy schemaCompatibilityStrategy = 
policies.schema_compatibility_strategy;
+        if (schemaCompatibilityStrategy == 
SchemaCompatibilityStrategy.UNDEFINED){
+            schemaCompatibilityStrategy = SchemaCompatibilityStrategy
+                    
.fromAutoUpdatePolicy(policies.schema_auto_update_compatibility_strategy);
+        }
+        return schemaCompatibilityStrategy;
     }
 
     @Deprecated
diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java
index f091d9a..65db37e 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/schema/compatibility/SchemaCompatibilityCheckTest.java
@@ -45,6 +45,7 @@ import java.util.concurrent.ThreadLocalRandom;
 
 import static org.apache.pulsar.common.naming.TopicName.PUBLIC_TENANT;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 
 @Slf4j
@@ -233,6 +234,9 @@ public class SchemaCompatibilityCheckTest extends 
MockedPulsarServiceBaseTest {
                 Sets.newHashSet(CLUSTER_NAME)
         );
 
+        
assertEquals(admin.namespaces().getSchemaCompatibilityStrategy(namespaceName.toString()),
+                SchemaCompatibilityStrategy.FULL);
+        
         
admin.namespaces().setSchemaCompatibilityStrategy(namespaceName.toString(), 
schemaCompatibilityStrategy);
         admin.schemas().createSchema(fqtn, 
Schema.AVRO(Schemas.PersonOne.class).getSchemaInfo());
 
diff --git 
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java
 
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java
index eb72052..9dc8699 100644
--- 
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java
+++ 
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java
@@ -1082,7 +1082,7 @@ public class CmdNamespaces extends CmdBase {
         }
     }
 
-    @Parameters(commandDescription = "Get the schema auto-update strategy for 
a namespace")
+    @Parameters(commandDescription = "Get the schema auto-update strategy for 
a namespace", hidden = true)
     private class GetSchemaAutoUpdateStrategy extends CliCommand {
         @Parameter(description = "tenant/namespace", required = true)
         private java.util.List<String> params;
@@ -1095,7 +1095,7 @@ public class CmdNamespaces extends CmdBase {
         }
     }
 
-    @Parameters(commandDescription = "Set the schema auto-update strategy for 
a namespace")
+    @Parameters(commandDescription = "Set the schema auto-update strategy for 
a namespace", hidden = true)
     private class SetSchemaAutoUpdateStrategy extends CliCommand {
         @Parameter(description = "tenant/namespace", required = true)
         private java.util.List<String> params;

Reply via email to