confluentinc/schema-registry

Client method `getSchemas()` does not inform about the version of the returned AVRO schemas

fmiguelez opened this issue · 0 comments

Even though REST call to endpoint /schemas returns corresponding version with each schema entry, in the object ParsedSchema (implemented by AvroSchema) is set to null.

The BUG is in this line of AvroSchemaProvider:

https://github.com/confluentinc/schema-registry/blob/9e7ab57e7f1d5664bc08f42ad9678c5b68a769d8/client/src/main/java/io/confluent/kafka/schemaregistry/avro/AvroSchemaProvider.java#L55C11-L55C15

It should set the version that comes in Schema object:

  @Override
  public ParsedSchema parseSchemaOrElseThrow(Schema schema, boolean isNew, boolean normalize) {
    try {
      return new AvroSchema(
          schema.getSchema(),
          schema.getReferences(),
          resolveReferences(schema),
          schema.getMetadata(),
          schema.getRuleSet(),
          schema.getVersion(), // Proposed change
          (validateDefaults || normalize) && isNew
      );
    } catch (Exception e) {
      log.error("Could not parse Avro schema", e);
      throw e;
    }
  }