From 4e8b0efc9418e26bd094932f9908af124b4dce25 Mon Sep 17 00:00:00 2001 From: Riya Mehta Date: Thu, 12 Jun 2025 16:20:07 -0700 Subject: [PATCH 1/2] S2A not available on platforms which netty-tcnative doesnn't support --- s2a/build.gradle | 10 ---------- .../java/io/grpc/s2a/S2AChannelCredentials.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) 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..8bea21c1d25 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()); 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() {} } From 44786b477e6c3d53283fdd8394219525ea1e95d7 Mon Sep 17 00:00:00 2001 From: Riya Mehta Date: Fri, 13 Jun 2025 08:45:33 -0700 Subject: [PATCH 2/2] add error message. --- s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java b/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java index 8bea21c1d25..349915ab43c 100644 --- a/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java +++ b/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java @@ -53,7 +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()); + checkState(isPlatformSupported(), "S2A is not suported on Windows or MacOS Intel"); return new Builder(s2aAddress, s2aChannelCredentials); }