lhotari commented on code in PR #24103:
URL: https://github.com/apache/pulsar/pull/24103#discussion_r2006980324
##########
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:
There's also a public `org.apache.avro.Schema#isUnion` method if that's the
only case to 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]