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_r333388320
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/SchemasResource.java
##########
@@ -314,34 +315,38 @@ public void postSchema(
NamespaceName namespaceName = NamespaceName.get(tenant, namespace);
getNamespacePoliciesAsync(namespaceName).thenAccept(policies -> {
- SchemaCompatibilityStrategy schemaCompatibilityStrategy =
SchemaCompatibilityStrategy
-
.fromAutoUpdatePolicy(policies.schema_auto_update_compatibility_strategy);
- byte[] data;
- if (SchemaType.KEY_VALUE.name().equals(payload.getType())) {
- data = DefaultImplementation
-
.convertKeyValueDataStringToSchemaInfoSchema(payload.getSchema().getBytes(Charsets.UTF_8));
- } else {
- data = payload.getSchema().getBytes(Charsets.UTF_8);
- }
- pulsar().getSchemaRegistryService().putSchemaIfAbsent(
- buildSchemaId(tenant, namespace, topic),
- SchemaData.builder()
+ SchemaCompatibilityStrategy schemaCompatibilityStrategy =
policies.schema_compatibility_strategy;
+ if (schemaCompatibilityStrategy ==
SchemaCompatibilityStrategy.UNDEFINED) {
+ schemaCompatibilityStrategy = SchemaCompatibilityStrategy
+
.fromAutoUpdatePolicy(policies.schema_auto_update_compatibility_strategy);
+ }
+ byte[] data;
+ if (SchemaType.KEY_VALUE.name().equals(payload.getType())) {
+ data = DefaultImplementation
+
.convertKeyValueDataStringToSchemaInfoSchema(payload.getSchema().getBytes(Charsets.UTF_8));
+ } else {
+ data = payload.getSchema().getBytes(Charsets.UTF_8);
+ }
+ pulsar().getSchemaRegistryService().putSchemaIfAbsent(
+ buildSchemaId(tenant, namespace, topic),
+ SchemaData.builder()
.data(data)
.isDeleted(false)
.timestamp(clock.millis())
.type(SchemaType.valueOf(payload.getType()))
.user(defaultIfEmpty(clientAppId(), ""))
.props(payload.getProperties())
.build(),
Review comment:
Add tab to format the builder
----------------------------------------------------------------
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