File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,14 @@ package kotlinx.coroutines.experimental.io
44
55import kotlinx.coroutines.experimental.CancellableContinuation
66import kotlinx.coroutines.experimental.channels.ClosedReceiveChannelException
7- import kotlinx.coroutines.experimental.channels.ClosedSendChannelException
87import kotlinx.coroutines.experimental.io.internal.*
98import kotlinx.coroutines.experimental.io.packet.*
109import kotlinx.coroutines.experimental.suspendCancellableCoroutine
1110import java.nio.BufferOverflowException
1211import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
1312
13+ internal const val DEFAULT_CLOSE_MESSAGE = " Byte channel was closed"
14+
1415// implementation for ByteChannel
1516internal class ByteBufferChannel (
1617 override val autoFlush : Boolean ,
@@ -1276,7 +1277,8 @@ internal class ByteBufferChannel(
12761277 c.resume(state.capacity.availableForRead > 0 )
12771278 }
12781279
1279- WriteOp .getAndSet(this , null )?.tryResumeWithException(cause ? : ClosedSendChannelException (null ))
1280+ WriteOp .getAndSet(this , null )?.tryResumeWithException(cause ? :
1281+ ClosedWriteChannelException (DEFAULT_CLOSE_MESSAGE ))
12801282 }
12811283
12821284 private tailrec suspend fun readSuspend (size : Int ): Boolean {
Original file line number Diff line number Diff line change 11package kotlinx.coroutines.experimental.io
22
3- import kotlinx.coroutines.experimental.io.packet.*
3+ import kotlinx.coroutines.experimental.io.packet.ByteReadPacket
4+ import kotlinx.coroutines.experimental.io.packet.ByteWritePacket
5+ import kotlinx.coroutines.experimental.io.packet.buildPacket
46import java.nio.ByteBuffer
57import java.nio.CharBuffer
68import java.util.concurrent.CancellationException
@@ -174,4 +176,9 @@ suspend fun ByteWriteChannel.writePacketSuspend(builder: suspend ByteWritePacket
174176 writePacket(buildPacket { builder() })
175177}
176178
177- class ClosedWriteChannelException (message : String? ) : CancellationException(message)
179+ /* *
180+ * Indicates attempt to write on [isClosedForWrite][ByteWriteChannel.isClosedForWrite] channel
181+ * that was closed without a cause. A _failed_ channel rethrows the original [close][ByteWriteChannel.close] cause
182+ * exception on send attempts.
183+ */
184+ public class ClosedWriteChannelException (message : String? ) : CancellationException(message)
You can’t perform that action at this time.
0 commit comments