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

ArrayIndexOutOfBoundsException during unsubscribe #78

Open
satyarajrapido opened this issue Oct 16, 2023 · 0 comments
Open

ArrayIndexOutOfBoundsException during unsubscribe #78

satyarajrapido opened this issue Oct 16, 2023 · 0 comments

Comments

@satyarajrapido
Copy link

satyarajrapido commented Oct 16, 2023

@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 is 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)
@satyarajrapido satyarajrapido changed the title Null topic being passed during unsubscribe ArrayIndexOutOfBoundsException during unsubscribe Oct 16, 2023
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

1 participant