diff --git a/s2a/build.gradle b/s2a/build.gradle index 1e48e2bb297..5845414716a 100644 --- a/s2a/build.gradle +++ b/s2a/build.gradle @@ -47,21 +47,11 @@ dependencies { classifier = "linux-aarch_64" } } - testRuntimeOnly (libraries.netty.tcnative) { - artifact { - classifier = "osx-x86_64" - } - } testRuntimeOnly (libraries.netty.tcnative) { artifact { classifier = "osx-aarch_64" } } - testRuntimeOnly (libraries.netty.tcnative) { - artifact { - classifier = "windows-x86_64" - } - } signature (libraries.signature.java) { artifact { diff --git a/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java b/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java index 4be32475205..349915ab43c 100644 --- a/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java +++ b/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.isNullOrEmpty; import com.google.common.annotations.VisibleForTesting; @@ -52,6 +53,7 @@ public final class S2AChannelCredentials { public static Builder newBuilder(String s2aAddress, ChannelCredentials s2aChannelCredentials) { checkArgument(!isNullOrEmpty(s2aAddress), "S2A address must not be null or empty."); checkNotNull(s2aChannelCredentials, "S2A channel credentials must not be null"); + checkState(isPlatformSupported(), "S2A is not suported on Windows or MacOS Intel"); return new Builder(s2aAddress, s2aChannelCredentials); } @@ -131,5 +133,20 @@ InternalProtocolNegotiator.ClientFactory buildProtocolNegotiatorFactory() { } } + /** + * S2A has a runtime dependency on netty-tcnative. This function returns true + * if netty-tcnative is supported on the current platform. + * + * @return whether S2A is supported on current platform + */ + private static boolean isPlatformSupported() { + if (System.getProperty("os.name").contains("Windows") + || (System.getProperty("os.name").contains("OS X") + && System.getProperty("os.arch").contains("x86_64"))) { + return false; + } + return true; + } + private S2AChannelCredentials() {} }