diff options
author | Carl Mastrangelo <notcarl@google.com> | 2018-09-24 18:36:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 18:36:07 -0700 |
commit | 5e4d9a591ede57b4271e5a6413c93e1be1d50001 (patch) | |
tree | 541ee08c33871325b4da9774db3425af9ef78711 /okhttp | |
parent | 693779dba776bb4f685a3d878840d4a45b5cd835 (diff) | |
download | grpc-grpc-java-5e4d9a591ede57b4271e5a6413c93e1be1d50001.tar.gz |
okhttp: include better ALPN error message and fine log some exceptions
Diffstat (limited to 'okhttp')
3 files changed, 5 insertions, 3 deletions
diff --git a/okhttp/src/main/java/io/grpc/okhttp/OkHttpProtocolNegotiator.java b/okhttp/src/main/java/io/grpc/okhttp/OkHttpProtocolNegotiator.java index 1858a9317..eabe385ff 100644 --- a/okhttp/src/main/java/io/grpc/okhttp/OkHttpProtocolNegotiator.java +++ b/okhttp/src/main/java/io/grpc/okhttp/OkHttpProtocolNegotiator.java @@ -93,7 +93,7 @@ class OkHttpProtocolNegotiator { String negotiatedProtocol = getSelectedProtocol(sslSocket); if (negotiatedProtocol == null) { - throw new RuntimeException("protocol negotiation failed"); + throw new RuntimeException("TLS ALPN negotiation failed with protocols: " + protocols); } return negotiatedProtocol; } finally { @@ -185,6 +185,7 @@ class OkHttpProtocolNegotiator { return new String(alpnResult, Util.UTF_8); } } catch (Exception e) { + logger.log(Level.FINE, "Failed calling getAlpnSelectedProtocol()", e); // In some implementations, querying selected protocol before the handshake will fail with // exception. } @@ -198,6 +199,7 @@ class OkHttpProtocolNegotiator { return new String(npnResult, Util.UTF_8); } } catch (Exception e) { + logger.log(Level.FINE, "Failed calling getNpnSelectedProtocol()", e); // In some implementations, querying selected protocol before the handshake will fail with // exception. } diff --git a/okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java b/okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java index 0a8672c65..e43713d66 100644 --- a/okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java +++ b/okhttp/src/main/java/io/grpc/okhttp/OkHttpTlsUpgrader.java @@ -43,7 +43,7 @@ final class OkHttpTlsUpgrader { */ @VisibleForTesting static final List<Protocol> TLS_PROTOCOLS = - Collections.unmodifiableList(Arrays.<Protocol>asList(Protocol.GRPC_EXP, Protocol.HTTP_2)); + Collections.unmodifiableList(Arrays.asList(Protocol.GRPC_EXP, Protocol.HTTP_2)); /** * Upgrades given Socket to be a SSLSocket. diff --git a/okhttp/src/test/java/io/grpc/okhttp/OkHttpProtocolNegotiatorTest.java b/okhttp/src/test/java/io/grpc/okhttp/OkHttpProtocolNegotiatorTest.java index 5f183dcdf..67d678258 100644 --- a/okhttp/src/test/java/io/grpc/okhttp/OkHttpProtocolNegotiatorTest.java +++ b/okhttp/src/test/java/io/grpc/okhttp/OkHttpProtocolNegotiatorTest.java @@ -128,7 +128,7 @@ public class OkHttpProtocolNegotiatorTest { OkHttpProtocolNegotiator negotiator = new OkHttpProtocolNegotiator(platform); thrown.expect(RuntimeException.class); - thrown.expectMessage("protocol negotiation failed"); + thrown.expectMessage("TLS ALPN negotiation failed"); negotiator.negotiate(sock, "hostname", ImmutableList.of(Protocol.HTTP_2)); } |