confluentinc / schema-registry

Confluent Schema Registry for Kafka
https://docs.confluent.io/current/schema-registry/docs/index.html
Other
2.21k stars 1.12k forks source link

ProtobufSchema is incompatible with `com.squareup.wire:wire-schema:5.0.0` #3325

Open mdub opened 1 hour ago

mdub commented 1 hour ago

I'm using io.confluent:kafka-protobuf-provider:7.7.1

After upgrading to com.squareup.wire:wire-schema:5.0.0 (or later), parsing a ProtobufSchema, e.g.

val protoSchemaText = """
  syntax = "proto2";

  package egg.sample;

  message SampleMessage {
    optional string sample_string = 1;
  }
""".trimIndent()

val schema = ProtobufSchema(protoSchemaText)

fails with an exception:

java.lang.NoSuchMethodError: 'void com.squareup.wire.schema.internal.parser.ExtensionsElement.<init>(com.squareup.wire.schema.Location, java.lang.String, java.util.List)'
    at io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema.toExtension(ProtobufSchema.java:1135)
    at io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema.toMessage(ProtobufSchema.java:951)
    at io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema.toProtoFile(ProtobufSchema.java:670)
    at io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema.<clinit>(ProtobufSchema.java:286)

I have a full working (well, failing) example in https://github.com/mdub/confluent-schema-registry-wire-upgrade/tree/sr-7.7.1-vs-wire-5.0.0.

It appears it was triggered by https://github.com/square/wire/pull/2966, which changed internal classes in a binary-incompatible way.

mdub commented 1 hour ago

This kind of binary incompatibility has happened before (refer https://github.com/confluentinc/schema-registry/issues/2715), and seems likely to happen again, given the use of "com.squareup.wire.schema.internal.parser" classes by the Confluent code.

I wonder if there is a way for Confluent to achieve the same thing, using only stable, public APIs. Do you have any suggestions, @oldergod?