diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/DefaultGrpcServerFactory.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/DefaultGrpcServerFactory.java index 957d311..510b7f9 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/DefaultGrpcServerFactory.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/DefaultGrpcServerFactory.java @@ -102,10 +102,10 @@ public class DefaultGrpcServerFactory> implements Grp @SuppressWarnings("unchecked") private T unixDomainServerBuilder(String path) { - if (NettyServerFactoryHelper.isAvailable()) { + if (NettyServerFactoryHelper.isEpollAvailable()) { return (T) NettyServerFactoryHelper.forUnixDomainSocket(path); } - else if (ShadedNettyServerFactoryHelper.isAvailable()) { + else if (ShadedNettyServerFactoryHelper.isEpollAvailable()) { return (T) ShadedNettyServerFactoryHelper.forUnixDomainSocket(path); } throw new IllegalStateException( diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/NettyServerFactoryHelper.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/NettyServerFactoryHelper.java index 2b911b1..19b91db 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/NettyServerFactoryHelper.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/NettyServerFactoryHelper.java @@ -30,13 +30,18 @@ import io.netty.channel.unix.DomainSocketAddress; class NettyServerFactoryHelper { - private static final boolean AVAILABLE = ClassUtils.isPresent("io.netty.channel.epoll.Epoll", null) - && Epoll.isAvailable(); + private static final boolean AVAILABLE = ClassUtils.isPresent("io.netty.channel.epoll.Epoll", null); + + private static final boolean EPOLL_AVAILABLE = AVAILABLE && Epoll.isAvailable(); public static boolean isAvailable() { return AVAILABLE; } + public static boolean isEpollAvailable() { + return EPOLL_AVAILABLE; + } + public static ServerBuilder forUnixDomainSocket(String path) { return NettyServerBuilder.forAddress(new DomainSocketAddress(path)) .channelType(EpollServerDomainSocketChannel.class) diff --git a/spring-grpc-core/src/main/java/org/springframework/grpc/server/ShadedNettyServerFactoryHelper.java b/spring-grpc-core/src/main/java/org/springframework/grpc/server/ShadedNettyServerFactoryHelper.java index ba69f97..2af1e56 100644 --- a/spring-grpc-core/src/main/java/org/springframework/grpc/server/ShadedNettyServerFactoryHelper.java +++ b/spring-grpc-core/src/main/java/org/springframework/grpc/server/ShadedNettyServerFactoryHelper.java @@ -31,12 +31,18 @@ import io.grpc.netty.shaded.io.netty.channel.unix.DomainSocketAddress; class ShadedNettyServerFactoryHelper { private static final boolean AVAILABLE = ClassUtils.isPresent("io.grpc.netty.shaded.io.netty.channel.epoll.Epoll", - null) && Epoll.isAvailable(); + null); + + private static final boolean EPOLL_AVAILABLE = AVAILABLE && Epoll.isAvailable(); public static boolean isAvailable() { return AVAILABLE; } + public static boolean isEpollAvailable() { + return EPOLL_AVAILABLE; + } + public static ServerBuilder forUnixDomainSocket(String path) { return NettyServerBuilder.forAddress(new DomainSocketAddress(path)) .channelType(EpollServerDomainSocketChannel.class)