Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: Reading is not available in state Reading #43

Closed
ScottPierce opened this issue Mar 14, 2019 · 2 comments

Comments

@ScottPierce
Copy link

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:
ktorio/ktor#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)
@cy6erGn0m
Copy link
Contributor

@e5l readRemaining() does never use lookahead nor readSession so it is unlikely kxio's bug. Most likely it is some kind undesired concurrency.

@fzhinkin
Copy link
Collaborator

We're rebooting the kotlinx-io development (see #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants