Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions okio/src/jvmMain/kotlin/okio/internal/DefaultSocket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ internal class DefaultSocket(val socket: JavaNetSocket) : Socket {
else -> {
if (socket.isClosed || socket.isOutputShutdown) return // Nothing to do.
outputStream.flush()
socket.shutdownOutput()
try {
socket.shutdownOutput()
} catch (_: UnsupportedOperationException) {
// Android API 21's SSLSocket doesn't implement this! So close the whole socket.
// https://github.com/square/okhttp/issues/9123
outputStream.close()
}
}
}
}
Expand Down Expand Up @@ -146,7 +152,13 @@ internal class DefaultSocket(val socket: JavaNetSocket) : Socket {
// Close this stream only.
else -> {
if (socket.isClosed || socket.isInputShutdown) return // Nothing to do.
socket.shutdownInput()
try {
socket.shutdownInput()
} catch (_: UnsupportedOperationException) {
// Android API 21's SSLSocket doesn't implement this! So close the whole socket.
// https://github.com/square/okhttp/issues/9123
inputStream.close()
}
}
}
}
Expand Down