confluentinc/schema-registry

MockSchemaRegistryClient doesn't generate new schema id with protobuf

Closed this issue · 1 comments

Given a protobuf file with multiple types defined, like this:

syntax = "proto3";
package com.example.kafka.schemas;

option java_multiple_files = true;

message Message1 {
  int64 amount = 1;
  int32 year = 2;
}

message Message2 {
  string description = 1;
}

When I try to reuse a MockSchemaRegistryClient instance between two tests that write/read in two different topics, it fails on the second test.

The problem seams to be here, the schema id is returned by schemaIdCache.get(schema), but fullName and Descriptor doesn't match, and in deserialization it fails.

A pet project that replicates the issue can be found at https://github.com/khaelys/spring-kafka-protobuf-issue.

I know that I could just create a new instance of MockSchemaRegistryClient between each test, but to me it seams a bug or an unsupported feature (have one proto for each message type solve the issue). Also it is difficult or unclean to reset the autoconfigured instance with Spring Boot in case of integration tests.

Actually this is a duplicate of #1869 which is fixed in 6.1.2. The latest changes to MockSchemaRegistryClient aren't necessary