Skip to content

Commit

Permalink
okhttp: Ignore known conscrypt socket close issue (#10811) (#10812)
Browse files Browse the repository at this point in the history
This stops an exception from being thrown when a known Conscrypt synchronization issue happens.
  • Loading branch information
temawi committed Jan 10, 2024
1 parent 5b082ca commit 2531563
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions okhttp/src/main/java/io/grpc/okhttp/OkHttpClientTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ class ClientFrameHandler implements FrameReader.Handler, Runnable {
}

@Override
@SuppressWarnings("Finally")
public void run() {
String threadName = Thread.currentThread().getName();
Thread.currentThread().setName("OkHttpClientTransport");
Expand Down Expand Up @@ -1130,6 +1131,15 @@ public void run() {
frameReader.close();
} catch (IOException ex) {
log.log(Level.INFO, "Exception closing frame reader", ex);
} catch (RuntimeException e) {
// This same check is done in okhttp proper:
// https://github.com/square/okhttp/blob/3cc0f4917cbda03cb31617f8ead1e0aeb19de2fb/okhttp/src/main/kotlin/okhttp3/internal/-UtilJvm.kt#L270

// Conscrypt in Android 10 and 11 may throw closing an SSLSocket. This is safe to ignore.
// https://issuetracker.google.com/issues/177450597
if (!"bio == null".equals(e.getMessage())) {
throw e;
}
}
listener.transportTerminated();
Thread.currentThread().setName(threadName);
Expand Down

0 comments on commit 2531563

Please sign in to comment.