8000 ArrayIndexOutOfBoundsException during unsubscribe · Issue #78 · gojek/courier-android · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ArrayIndexOutOfBoundsException during unsubscribe #78
Open
@satyarajrapido

Description

@satyarajrapido

@deepanshu42 I was observing a crash in Coordinator due to the following code in the SDK, if you see the block topics.size == 1 it would unsubscribe to the first topic, which i 5F1E s fine, but let's say, the topic size is zero, then the else querying the topics[0] will throw ArrayIndexOutOfBoundsException,

This is the same even for subscribeAll too, please check

override fun unsubscribe(stubMethod: StubMethod.Unsubscribe, args: Array<Any>): Any {
        logger.d("Coordinator", "Unsubscribe method invoked")
        stubMethod.argumentProcessor.inject(args)
        val topics = stubMethod.argumentProcessor.getTopics()
        val status = if (topics.size == 1) {
            client.unsubscribe(topics[0])
        } else {
            client.unsubscribe(topics[0], *topics.sliceArray(IntRange(1, topics.size - 1)))
        }
        logger.d("Coordinator", "Unsubscribing topics: $topics")
        return status
    }

Crash stacktrace

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
       at com.gojek.courier.coordinator.Coordinator.unsubscribe(Coordinator.kt:133)
       at com.gojek.courier.stub.StubInterface.invoke(StubInterface.kt:32)
       at com.gojek.courier.stub.ProxyFactory.createInvocationHandler$lambda-0(ProxyFactory.kt:41)
       at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
       at $Proxy48.unsubscribe()
       at okyi.okyi.okyi.XNkf.kDyL.OEVx.OEVx.HVAU$IwUN.invokeSuspend(OperatorImpl.kt:21)
       at okyi.okyi.okyi.XNkf.kDyL.OEVx.OEVx.HVAU$IwUN.invoke(OperatorImpl.kt:2)
       at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo$suspendImpl(Builders.kt:320)
       at kotlinx.coroutines.flow.ChannelFlowBuilder.collectTo(Builders.kt)
       at kotlinx.coroutines.flow.CallbackFlowBuilder.collectTo(Builders.kt:334)
       at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
       at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0