Skip to content

GrpcSslConfigurer beans are activated when no grpc-netty is present #4169

@ViliusS

Description

@ViliusS

Describe the bug
Currently grpc-netty is marked as optional dependency of Spring Cloud Gateway server. jsonToGRPCFilterFactory and gRPCSSLContext beans from the looks of it are also only used for functionality which is not really mandatory.

The problem is that if grpc-api dependency is added to the Spring Cloud Gateway server project (though some external requirement), those GRPC beans get activated which then causes java.lang.NoClassDefFoundError: io/grpc/netty/NettyChannelBuilder.

That's because

and relies on io.grpc.Channel which is included in grpc-api.

This produces all sorts of issues when gateway is used with 3rd party dependencies. For example: #2769

The only workaround in such case is to include full grpc-netty dependency even if it is never really used by the gateway.

IMHO, much better solution would be for these beans to rely on io.grpc.netty.GrpcSslContexts or io.grpc.netty.NettyChannelBuilder which is actually used in GrpcSslConfigurer.

Sample
Create standard Spring Cloud Gateway server project and add:

        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-api</artifactId>
        </dependency>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions