poorbarcode commented on code in PR #24103:
URL: https://github.com/apache/pulsar/pull/24103#discussion_r2013783724
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java:
##########
@@ -123,8 +125,41 @@ 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());
+ switch (schema.getType()) {
+ case RECORD: {
+ break;
+ }
+ case UNION: {
+ return CompletableFuture.failedFuture(new
RestException(
+ Response.Status.BAD_REQUEST.getStatusCode(),
+ "[" + String.valueOf(topicName) + "] Avro
schema typed [UNION] is not supported"));
+ }
+ case INT:
+ case LONG:
+ case FLOAT:
+ case DOUBLE:
+ case BOOLEAN:
+ case STRING:
+ case BYTES: {
Review Comment:
> would it make sense to have a default case instead?
No, if users can register an Avro schema successfully, they will try to use
the same schema to consume, and then they will get an error. We'd better deny
this operation
--
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]