lhotari commented on code in PR #24103:
URL: https://github.com/apache/pulsar/pull/24103#discussion_r2006975772
##########
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:
Avro Schema contains a public method `getType()` which returns an enum .
`org.apache.avro.Schema.Type`. That should be used instead to perform the
check.
--
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]