kotlinx-io
kotlinx-io copied to clipboard
java.lang.IllegalStateException: Reading is not available in state Reading
I'm seeing this bug in ktor client 1.1.3 on Android with OkHttp as the engine. It appears to have been a bug since at least ktor 1.0.1. You can see people posting this bug here: https://github.com/ktorio/ktor/issues/813
2019-03-14 12:53:57.109 2002-2002 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rally.coach.internal.debug, PID: 2002
java.lang.IllegalStateException: Reading is not available in state Reading
at kotlinx.coroutines.io.internal.ReadWriteBufferState.startReading$kotlinx_coroutines_io(ReadWriteBufferState.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.readAsMuchAsPossible(ByteBufferChannel.kt:2573)
at kotlinx.coroutines.io.ByteBufferChannel.readAsMuchAsPossible$default(ByteBufferChannel.kt:436)
at kotlinx.coroutines.io.ByteBufferChannel.readRemaining(ByteBufferChannel.kt:2161)
at kotlinx.coroutines.io.ByteReadChannelKt.readRemaining(ByteReadChannel.kt:175)
at io.ktor.client.response.HttpResponseKt.readText(HttpResponse.kt:75)
at io.ktor.client.response.HttpResponseKt.readText$default(HttpResponse.kt:74)
at com.rally.coach.api.service.utils.ApiExceptionUtilKt.toApiException(ApiExceptionUtil.kt:18)
at com.rally.coach.api.BaseApi.withApiContext(BaseApi.kt:46)
at com.rally.coach.api.BaseApi$withApiContext$1.invokeSuspend(Unknown Source:32)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:285)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@e5l readRemaining()
does never use lookahead nor readSession so it is unlikely kxio's bug. Most likely it is some kind undesired concurrency.
We're rebooting the kotlinx-io development (see https://github.com/Kotlin/kotlinx-io/issues/131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version.