apache / rocketmq-schema-registry

Apache RocketMQ Schema Registry
https://rocketmq.apache.org/
31 stars 20 forks source link

Why will an exception be thrown when the schema does not exist? #62

Open sunxiaojian opened 2 years ago

sunxiaojian commented 2 years ago

Whether an independent interface is provided to check whether the schema exists

Server:

image

client:

image

humkum commented 2 years ago

I may not understand your request, but I found that if there didn't throw an exception. It would cause NPE in GetSchemaResponse constructor as follows:

public GetSchemaResponse(QualifiedName name, SchemaRecordInfo schemaRecordInfo) {
        this.subjectFullName = name.subjectFullName();
        this.schemaFullName = schemaRecordInfo.getSchema();
        this.recordId = CommonUtil.getSchemaRecordId(schemaRecordInfo.getSchemaId(),
            schemaRecordInfo.getVersion());
        this.idl = schemaRecordInfo.getIdl();
        this.dependency = schemaRecordInfo.getDependency();
        this.type = schemaRecordInfo.getType();
        this.fields = parse(idl);
    }
ni-ze commented 1 year ago

@humkum, IMO, If the result is empty, return null, or empty list is recommended. We will not construct a GetSchemaResponse with this constructor.