confluentinc / schema-registry

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

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

Closed mdub closed 1 month ago

mdub commented 1 month 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 month 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?

oldergod commented 1 month ago

We're doing our best in Wire not to break public APIs, and that still might happens from time to time. Data classes are very difficult to change without breaking backward compatibility (this is why Wire doesn't generate data classes btw). If Schema Registry is having trouble because of its usage of an internal Wire API, then I would recommend migrating out of it.

rayokota commented 1 month ago

Support for wire-schema 5.0.0 will available in 7.8.0