Skip to content

Compatible issue with old grpc version #203

Closed
@GAATTC0

Description

@GAATTC0

Environment

I use grpc io.grpc:protoc-gen-grpc-java:1.15.1 for code generation:

protobuf {
    plugins {
        id("grpc") {
        artifact = "io.grpc:protoc-gen-grpc-java:1.15.1"
        }
    }
}

Cause

the generated BlockingStub extends AbstractStub by this version, not AbstractBlockingStub:

Image

when creating stub on start, it is not match correctly in BlockingStubFactory:

Image

because it's just judge if extends AbstractBlockingStub and !type.getSimpleName().contains("BlockingV2")

i tried change the plugin version to 1.30.0, BlockingStub in generated code extends AbstractBlockingStub, it works now.

Issue

i think we can change the predicate to make compatible with old version:

    public class BlockingStubFactory extends AbstractStubFactory<AbstractBlockingStub<?>> implements Ordered {

        @Override
        public boolean supports(Class<?> type) {
            return (AbstractStubFactory.supports(AbstractBlockingStub.class, type) && !type.getSimpleName().contains("BlockingV2"))
                    || type.getSimpleName().endsWith("BlockingStub");
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions