Special treatment for a Windows-specific IOException
"IOException: The specified network name is no longer available" is treated as the end of channel
Test: existing
Bug: 336622305
Bug: 330395367
Change-Id: I996fdb8724518c4b96fc455045354484942e5f59
diff --git a/adblib/src/com/android/adblib/impl/channels/ChannelReadOrWriteHandler.kt b/adblib/src/com/android/adblib/impl/channels/ChannelReadOrWriteHandler.kt
index d9fc551..7bcaf68 100644
--- a/adblib/src/com/android/adblib/impl/channels/ChannelReadOrWriteHandler.kt
+++ b/adblib/src/com/android/adblib/impl/channels/ChannelReadOrWriteHandler.kt
@@ -22,6 +22,7 @@
import com.android.adblib.impl.TimeoutTracker
import kotlinx.coroutines.CancellableContinuation
import java.io.EOFException
+import java.io.IOException
import java.nio.ByteBuffer
import java.nio.channels.AsynchronousCloseException
import java.nio.channels.AsynchronousFileChannel
@@ -106,6 +107,17 @@
e
}
}
+
+ override fun failed(e: Throwable, continuation: CancellableContinuation<Unit>) {
+ if (e is IOException &&
+ e.message == "The specified network name is no longer available") {
+ // Treat this Windows-specific exception as the end of channel.
+ completionHandlerCompleted(-1, continuation)
+ }
+ else {
+ super.failed(e, continuation)
+ }
+ }
}
/**