java.lang.IllegalStateException: Reading is not available in state Reading
See original GitHub issueKtor Version
1.0.1
Ktor Engine Used(client or server and name)
Netty / Firefox
JVM Version, Operating System and Relevant Context
1.8 Windows Server 2008R2
Feedback
I don’t how this happen, I can’t reproduce it.
stacktrace:
500 Internal Server Error: POST - /search/TT
java.lang.IllegalStateException: Reading is not available in state Reading
at kotlinx.coroutines.io.internal.ReadWriteBufferState.startReading$kotlinx_coroutines_io_jvm(ReadWriteBufferSta
te.kt:19)
at kotlinx.coroutines.io.ByteBufferChannel.setupStateForRead(ByteBufferChannel.kt:238)
at kotlinx.coroutines.io.ByteBufferChannel.access$setupStateForRead(ByteBufferChannel.kt:21)
at kotlinx.coroutines.io.ByteBufferChannel.lookAhead(ByteBufferChannel.kt:2868)
at kotlinx.coroutines.io.DelimitedKt.readUntilDelimiter(Delimited.kt:24)
at io.ktor.http.cio.MultipartKt.copyUntilBoundary(Multipart.kt:339)
at io.ktor.http.cio.MultipartKt$copyUntilBoundary$1.invokeSuspend(Multipart.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedContinuation.resumeWith(Dispatched.kt:111)
at kotlinx.coroutines.io.internal.CancellableReusableContinuation.resumeWith(CancellableReusableContinuation.kt:
83)
at kotlinx.coroutines.io.ByteBufferChannel.resumeWriteOp(ByteBufferChannel.kt:2207)
at kotlinx.coroutines.io.ByteBufferChannel.bytesRead(ByteBufferChannel.kt:865)
at kotlinx.coroutines.io.ByteBufferChannel.readAsMuchAsPossible(ByteBufferChannel.kt:426)
at kotlinx.coroutines.io.ByteBufferChannel.readAvailable(ByteBufferChannel.kt:559)
at kotlinx.coroutines.io.ByteBufferChannel.readAvailableSuspend(ByteBufferChannel.kt:593)
at kotlinx.coroutines.io.ByteBufferChannel$readAvailableSuspend$2.invokeSuspend(ByteBufferChannel.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:236)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
java.lang.IllegalStateException when using State in Android ...
I have ViewModel with Kotlin sealed class to provide different states for UI. Also, I use androidx ...
Read more >How to Fix The IllegalStateException in Java - Rollbar
The IllegalStateException is thrown when the Java environment or application is not in an appropriate state for the requested operation.
Read more >How to Solve java.lang.IllegalStateException in Java main ...
IllegalStateException in Java main Thread we must ensure that any method in our code cannot be called at an illegal or an inappropriate...
Read more >java.lang.IllegalStateException: Reading a state that was ...
java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied.
Read more >IllegalStateException when writing in coroutine context ...
Exception in thread "DefaultDispatcher-worker-1" java.lang.IllegalStateException: Writing is not available in state Writing at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I upgraded ktor to 1.2.2. But this issue exists still. The client is commons-httpclient. The server OS is CentOS7. After this exeption happens, all clients will be blocked forever(without timeout settings). Stacktrace is:
@cy6erGn0m Please take a look, thanks
@e5l same here: according to the stacktrace
readUntilDelimiter
does enterlookAhead
and fails immediately because we already have reading state. I see no way how any read operation could leave reading state unreleased without exceptions that usually kill everything.