Skip to content

Commit b888a24

Browse files
committed
Skip TlsTest on old JDK 8 versions
1 parent 9a9cba7 commit b888a24

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

okhttp/src/main/java/io/grpc/okhttp/OkHttpServerBuilder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,7 @@ private Socket apply(Socket s) throws IOException {
519519
return sslSocket;
520520
}
521521

522-
@Override
523-
public Socket createSocket(Socket s, String host, int port, boolean autoClose)
522+
@Override public Socket createSocket(Socket s, String host, int port, boolean autoClose)
524523
throws IOException {
525524
return apply(socketFactory.createSocket(s, host, port, autoClose));
526525
}

okhttp/src/test/java/io/grpc/okhttp/TlsTest.java

+18
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
import io.grpc.testing.protobuf.SimpleServiceGrpc;
4040
import java.io.IOException;
4141
import java.io.InputStream;
42+
import javax.net.ssl.SSLContext;
43+
import javax.net.ssl.SSLEngine;
44+
import org.junit.Assume;
45+
import org.junit.Before;
4246
import org.junit.Rule;
4347
import org.junit.Test;
4448
import org.junit.runner.RunWith;
@@ -50,6 +54,20 @@ public class TlsTest {
5054
@Rule
5155
public final GrpcCleanupRule grpcCleanupRule = new GrpcCleanupRule();
5256

57+
@Before
58+
public void checkForAlpnApi() throws Exception {
59+
// This checks for the "Java 9 ALPN API" which was backported to Java 8u252. The Kokoro Windows
60+
// CI is on too old of a JDK for us to assume this is available.
61+
SSLContext context = SSLContext.getInstance("TLS");
62+
context.init(null, null, null);
63+
SSLEngine engine = context.createSSLEngine();
64+
try {
65+
SSLEngine.class.getMethod("getApplicationProtocol").invoke(engine);
66+
} catch (NoSuchMethodException | UnsupportedOperationException ex) {
67+
Assume.assumeNoException(ex);
68+
}
69+
}
70+
5371
@Test
5472
public void mtls_succeeds() throws Exception {
5573
ServerCredentials serverCreds;

0 commit comments

Comments
 (0)