rsocket-rpc-java icon indicating copy to clipboard operation
rsocket-rpc-java copied to clipboard

RSocket Protoc 0.2.19 generates invalid protobuf code for rsocket-java 1.0.1

Open ghost opened this issue 5 years ago • 5 comments

Expected Behavior

When running the generateProto task using the latest version of io.rsocket.rpc:rsocket-rpc-core/io.rsocket.rpc:rsocket-rpc-protobuf (0.2.19) and the latest version of io.rsocket:rsocket-core (1.0.1), the generated code can be compiled without any issues.

Actual Behavior

When running the generateProto task using the latest version of io.rsocket.rpc:rsocket-rpc-core/io.rsocket.rpc:rsocket-rpc-protobuf (0.2.19) and the latest version of io.rsocket:rsocket-core (1.0.1), I get an error inside generated-sources/main/rsocketRpc/com/rsocket/rpc/Blocking...Service.java:

Cannot resolve symbol 'SwitchTransformFlux'

This is because of the following snippet:

  @java.lang.Override
  public reactor.core.publisher.Flux<io.rsocket.Payload> requestChannel(org.reactivestreams.Publisher<io.rsocket.Payload> payloads) {
    return new io.rsocket.internal.SwitchTransformFlux<io.rsocket.Payload, io.rsocket.Payload>(payloads, new java.util.function.BiFunction<io.rsocket.Payload, reactor.core.publisher.Flux<io.rsocket.Payload>, org.reactivestreams.Publisher<? extends io.rsocket.Payload>>() {
      @java.lang.Override
      public org.reactivestreams.Publisher<io.rsocket.Payload> apply(io.rsocket.Payload payload, reactor.core.publisher.Flux<io.rsocket.Payload> publisher) {
        return requestChannel(payload, publisher);
      }
    });
  }

It seems to me like the SwitchTransformFlux class got removed/replaced in version 1.0.0 of rsocket-java. When I downgrade to 0.12.1, the error is gone. None the less, this is an issue as a lot of dependencies (e.g. the spring boot rsocket starter lib) already use v1.X and therefore cannot produce valid code.

Steps to Reproduce

  1. Import io.rsocket:rsocket-core:1.0.1
  2. Import io.rsocket.rpc:rsocket-rpc-core:0.2.19
  3. Import io.rsocket.rpc:rsocket-rpc-protobuf:0.2.19
  4. Create a .proto file with a service that uses a channel
service SomeService {
  rpc channel(stream SomeRequest) returns (stream SomeResponse) {}
}
  1. Generate the protobuf classes (e.g. ./gradlew generateProto)
  2. Try to compile the blocking server implementation (generated-sources/main/rsocketRpc/com/rsocket/rpc/BlockingSomeServiceServer.java)

Should fail with the exception mentioned above.

Possible Solution

Either reintroduce SwitchTransformFlux or change the rsocket protoc to not use it anymore.

Your Environment

  • io.rsocket:rsocket-core:1.0.1
  • io.rsocket.rpc:rsocket-rpc-core:0.2.19
  • io.rsocket.rpc:rsocket-rpc-protobuf:0.2.19
  • com.google.protobuf:protoc:3.12.1
  • com.google.protobuf:protobuf-java:3.12.1

ghost avatar Jul 03 '20 07:07 ghost

Ooops, of course you're right @OlegDokuka :) Thanks for transferring!

ghost avatar Jul 03 '20 07:07 ghost

Also, seems like this already got mentioned in #65 😬

ghost avatar Jul 03 '20 07:07 ghost

@OlegDokuka , hi, is it possible to make a fix of this bug in the nearest future? Our work depends a lot on rsocket and we cannot upgrade it without this fix. Thanks.

eksd avatar Sep 28 '20 13:09 eksd

@eksd I will take a look at that today.

Cheers, Oleh

OlegDokuka avatar Sep 28 '20 14:09 OlegDokuka

@OlegDokuka , did you have a chance to take a look at that bug?

Thanks.

eksd avatar Oct 09 '20 08:10 eksd