googleapis / java-pubsub

Apache License 2.0
127 stars 90 forks source link

Library Compatibility with Protobuf-Java 4.26.x+ #2034

Closed lqiu96 closed 1 month ago

lqiu96 commented 4 months ago

Protobuf has released v26.x+ which introduces a bunch of breaking changes for Protobuf-Java. Release notes for the version can be found at https://github.com/protocolbuffers/protobuf/releases/tag/v26.0

We have identified the generated StateProto.java from us-states.proto has a bunch of references to removed methods.

The generated proto files should be re-generated with the latest protoc version (i.e. 3.25.x+). Investigate if the proto file needs to be updated before re-generating.

See this doc for more information.

kutlueren commented 3 months ago

We have encountered a similar problem. I have upgraded our Protobuf version to 4.26.1 and the pubsub library started failing due to depending on the version 3.25.3 of Protobuf.

emintz commented 2 months ago

Compiling

  ByteString data = event.toByteString();
  PubsubMessage notification = PubsubMessage.newBuilder()
      .setData(data)
      .build();

generates java: cannot access com.google.protobuf.GeneratedMessageV3.Builder class file for com.google.protobuf.GeneratedMessageV3$Builder not found

Regenerating us-states-proto is probably not enough to fix the problem.

Further info when available.

lqiu96 commented 1 month ago

Protobuf-Java 4.27.4 was released (https://github.com/protocolbuffers/protobuf/releases/tag/v27.4) and re-introduced the shims to be compatible. I believe we can recompile the protos with Protoc 27.4

CC: @michaelpri10