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
4
4
5
5
import kotlinx.coroutines.experimental.CancellableContinuation
6
6
import kotlinx.coroutines.experimental.channels.ClosedReceiveChannelException
7
- import kotlinx.coroutines.experimental.channels.ClosedSendChannelException
8
7
import kotlinx.coroutines.experimental.io.internal.*
9
8
import kotlinx.coroutines.experimental.io.packet.*
10
9
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
11
10
import java.nio.BufferOverflowException
12
11
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
13
12
13
+ internal const val DEFAULT_CLOSE_MESSAGE = " Byte channel was closed"
14
+
14
15
// implementation for ByteChannel
15
16
internal class ByteBufferChannel (
16
17
override val autoFlush : Boolean ,
@@ -1276,7 +1277,8 @@ internal class ByteBufferChannel(
1276
1277
c.resume(state.capacity.availableForRead > 0 )
1277
1278
}
1278
1279
1279
- WriteOp .getAndSet(this , null )?.tryResumeWithException(cause ? : ClosedSendChannelException (null ))
1280
+ WriteOp .getAndSet(this , null )?.tryResumeWithException(cause ? :
1281
+ ClosedWriteChannelException (DEFAULT_CLOSE_MESSAGE ))
1280
1282
}
1281
1283
1282
1284
private tailrec suspend fun readSuspend (size : Int ): Boolean {
Original file line number Diff line number Diff line change 1
1
package kotlinx.coroutines.experimental.io
2
2
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
4
6
import java.nio.ByteBuffer
5
7
import java.nio.CharBuffer
6
8
import java.util.concurrent.CancellationException
@@ -174,4 +176,9 @@ suspend fun ByteWriteChannel.writePacketSuspend(builder: suspend ByteWritePacket
174
176
writePacket(buildPacket { builder() })
175
177
}
176
178
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