Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible JDK 11 fixes #4138

Merged
merged 5 commits into from Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@ language: java

jdk:
- oraclejdk8
# - openjdk11

addons:
apt:
Expand Down
7 changes: 7 additions & 0 deletions okhttp-tests/src/test/java/okhttp3/CallTest.java
Expand Up @@ -48,6 +48,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLProtocolException;
Expand Down Expand Up @@ -83,6 +84,7 @@
import static java.net.CookiePolicy.ACCEPT_ORIGINAL_SERVER;
import static okhttp3.TestUtil.awaitGarbageCollection;
import static okhttp3.TestUtil.defaultClient;
import static okhttp3.internal.platform.PlatformTest.getPlatform;
import static okhttp3.tls.internal.TlsUtil.localhost;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -1072,6 +1074,7 @@ private void postBodyRetransmittedAfterAuthorizationFail(String body) throws Exc
server.enqueue(new MockResponse().setBody("response that will never be received"));
RecordedResponse response = executeSynchronously("/");
response.assertFailure(
SSLException.class, // JDK 11 response to the FAIL_HANDSHAKE
SSLProtocolException.class, // RI response to the FAIL_HANDSHAKE
SSLHandshakeException.class // Android's response to the FAIL_HANDSHAKE
);
Expand Down Expand Up @@ -1168,6 +1171,10 @@ private void postBodyRetransmittedAfterAuthorizationFail(String body) throws Exc
// RI response to the FAIL_HANDSHAKE
} catch (SSLHandshakeException expected) {
// Android's response to the FAIL_HANDSHAKE
} catch (SSLException expected) {
// JDK 11 response to the FAIL_HANDSHAKE
String jvmVersion = System.getProperty("java.specification.version");
assertEquals("11", jvmVersion);
}
}

Expand Down
3 changes: 3 additions & 0 deletions okhttp-tests/src/test/java/okhttp3/URLConnectionTest.java
Expand Up @@ -3395,6 +3395,9 @@ private void zeroLengthPayload(String method) throws Exception {
// RI response to the FAIL_HANDSHAKE
} catch (SSLHandshakeException expected) {
// Android's response to the FAIL_HANDSHAKE
} catch (SSLException expected) {
// JDK 1.9 response to the FAIL_HANDSHAKE
// javax.net.ssl.SSLException: Unexpected handshake message: client_hello
} catch (SocketException expected) {
// Conscrypt's response to the FAIL_HANDSHAKE
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocketFactory;
Expand All @@ -46,6 +47,7 @@
import static okhttp3.tls.internal.TlsUtil.newKeyManager;
import static okhttp3.tls.internal.TlsUtil.newTrustManager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public final class ClientAuthTest {
Expand Down Expand Up @@ -181,6 +183,9 @@ public void setUp() {
call.execute();
fail();
} catch (SSLHandshakeException expected) {
} catch (SSLException expected) {
String jvmVersion = System.getProperty("java.specification.version");
assertEquals("11", jvmVersion);
} catch (SocketException expected) {
assertEquals("jdk9", getPlatform());
}
Expand Down Expand Up @@ -229,6 +234,10 @@ public void setUp() {
call.execute();
fail();
} catch (SSLHandshakeException expected) {
} catch (SSLException expected) {
// javax.net.ssl.SSLException: readRecord
String jvmVersion = System.getProperty("java.specification.version");
assertEquals("11", jvmVersion);
} catch (SocketException expected) {
assertEquals("jdk9", getPlatform());
}
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLProtocolException;
Expand Down Expand Up @@ -123,7 +124,9 @@ public boolean connectionFailed(IOException e) {

// On Android, SSLProtocolExceptions can be caused by TLS_FALLBACK_SCSV failures, which means we
// retry those when we probably should not.
return (e instanceof SSLHandshakeException || e instanceof SSLProtocolException);
return (e instanceof SSLHandshakeException
|| e instanceof SSLProtocolException
|| e instanceof SSLException);
}

/**
Expand Down