lhotari commented on code in PR #24103: URL: https://github.com/apache/pulsar/pull/24103#discussion_r2013817191
########## 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 @poorbarcode what I meant is using a `default` case for the `switch`, instead of listing all other cases. Does your comment apply to that? -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org