This commit is contained in:
Riya Mehta 2025-07-17 07:38:59 +08:00 committed by GitHub
commit caa09b5059
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 10 deletions

View File

@ -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 {

View File

@ -18,6 +18,7 @@ package io.grpc.s2a;
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 @@ public final class S2AChannelCredentials {
}
}
/**
* 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() {}
}