grpc-spring icon indicating copy to clipboard operation
grpc-spring copied to clipboard

Failed autowired *BlockingV2Stub type generated by gRPC-java 1.70.0

Open seal90 opened this issue 8 months ago • 0 comments

The context

The flow autowired will fail, and the main configuration. The new *BlockingV2Stub from https://github.com/grpc/grpc-java/commit/ea8c31c305eac5a6ac9a09de5ea2edb9ed719a31 commit.

    @GrpcClient("hello")
    private HelloWorldGrpc.HelloWorldBlockingV2Stub helloWorldBlockingV2Stub;
    <grpc.version>1.70.0</grpc.version>
    <protobuf.version>3.25.5</protobuf.version>

// User Code definitions
service HelloWorld {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}

  rpc ToSayHello (HelloRequest) returns (stream HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

Both HelloWorldBlockingV2Stub and HelloWorldBlockingStub extends AbstractBlockingStub so BlockingStubFactory cann't work well. FallbackStubFactory can work.

public static final class HelloWorldBlockingV2Stub
      extends io.grpc.stub.AbstractBlockingStub<HelloWorldBlockingV2Stub>{...}

public static final class HelloWorldBlockingStub
    extends io.grpc.stub.AbstractBlockingStub<HelloWorldBlockingStub> {...}
public class BlockingStubFactory extends StandardJavaGrpcStubFactory {

    @Override
    public boolean isApplicable(Class<? extends AbstractStub<?>> stubType) {
        return AbstractBlockingStub.class.isAssignableFrom(stubType);
    }

    @Override
    protected String getFactoryMethodName() {
        return "newBlockingStub";
    }
}

The bug

What's the problem? What's not working? What do you expect to happen.

Stacktrace and logs

Is there a stacktrace or a hint in the logs? (very important) Screenshots work as well, but don't screenshot your logs.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

The application's environment

Which versions do you use?

  • Spring (boot):
  • grpc-java:
  • grpc-spring-boot-starter:
  • java: version + architecture (64bit?)
  • Other relevant libraries...

Additional context

  • Did it ever work before?
  • Do you have a demo?

seal90 avatar Apr 06 '25 12:04 seal90