File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
okio/src/jvmMain/kotlin/okio/internal Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,13 @@ internal class DefaultSocket(val socket: JavaNetSocket) : Socket {
9292 else -> {
9393 if (socket.isClosed || socket.isOutputShutdown) return // Nothing to do.
9494 outputStream.flush()
95- socket.shutdownOutput()
95+ try {
96+ socket.shutdownOutput()
97+ } catch (_: UnsupportedOperationException ) {
98+ // Android API 21's SSLSocket doesn't implement this! So close the whole socket.
99+ // https://github.com/square/okhttp/issues/9123
100+ outputStream.close()
101+ }
96102 }
97103 }
98104 }
@@ -146,7 +152,13 @@ internal class DefaultSocket(val socket: JavaNetSocket) : Socket {
146152 // Close this stream only.
147153 else -> {
148154 if (socket.isClosed || socket.isInputShutdown) return // Nothing to do.
149- socket.shutdownInput()
155+ try {
156+ socket.shutdownInput()
157+ } catch (_: UnsupportedOperationException ) {
158+ // Android API 21's SSLSocket doesn't implement this! So close the whole socket.
159+ // https://github.com/square/okhttp/issues/9123
160+ inputStream.close()
161+ }
150162 }
151163 }
152164 }
You can’t perform that action at this time.
0 commit comments