poorbarcode commented on code in PR #24103:
URL: https://github.com/apache/pulsar/pull/24103#discussion_r2013227954
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java:
##########
@@ -123,8 +125,28 @@ public CompletableFuture<SchemaVersion>
deleteSchemaAsync(boolean authoritative,
});
}
+ protected CompletableFuture<Void>
checkSchemaTypeSupported(PostSchemaPayload payload) {
+ switch (SchemaType.valueOf(payload.getType())) {
+ case AVRO : {
+ Schema schema =
SchemaUtil.parseAvroSchema(payload.getSchema());
+ try {
+ // Pulsar only support "RecordSchema" so far. Other types
will throw an error when calls
+ // "getFields".
+ // Since "RecordSchema" is an avro internal private class,
we can not use "instanceof" here.
+ schema.getFields();
+ } catch (Exception e) {
+ return CompletableFuture.failedFuture(new
RestException(Response.Status.BAD_REQUEST.getStatusCode(),
+ "[" + String.valueOf(topicName) + "] Avro schema
typed [" + schema.getType() + "]"
+ + " is not supported"));
+ }
Review Comment:
Thanks, improved. And added a new test
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java:
##########
@@ -123,8 +125,28 @@ public CompletableFuture<SchemaVersion>
deleteSchemaAsync(boolean authoritative,
});
}
+ protected CompletableFuture<Void>
checkSchemaTypeSupported(PostSchemaPayload payload) {
+ switch (SchemaType.valueOf(payload.getType())) {
+ case AVRO : {
+ Schema schema =
SchemaUtil.parseAvroSchema(payload.getSchema());
+ try {
+ // Pulsar only support "RecordSchema" so far. Other types
will throw an error when calls
+ // "getFields".
+ // Since "RecordSchema" is an avro internal private class,
we can not use "instanceof" here.
+ schema.getFields();
+ } catch (Exception e) {
+ return CompletableFuture.failedFuture(new
RestException(Response.Status.BAD_REQUEST.getStatusCode(),
+ "[" + String.valueOf(topicName) + "] Avro schema
typed [" + schema.getType() + "]"
+ + " is not supported"));
+ }
Review Comment:
Thanks, improved. And added a new test for the simple typed schema
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]