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

IllegalStateException: Flow exception transparency is violated #323

Closed
gnarea opened this issue Jan 10, 2024 · 1 comment · Fixed by relaycorp/relaynet-gateway-android#727
Assignees
Labels
bug Something isn't working

Comments

@gnarea
Copy link
Member

gnarea commented Jan 10, 2024

The Awala gateway just crashed because of the exception above.

Unfortunately, the logs prior to the crash were lost by the time I plugged the phone (Pixel 8) to the computer, but I captured this which suggests a bug in this library:

2024-01-10 17:15:26.024  9441-9441  AndroidRuntime          pid-9441                             E  FATAL EXCEPTION: main
                                                                                                    Process: tech.relaycorp.gateway, PID: 9441
                                                                                                    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:562)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    Caused by: java.lang.reflect.InvocationTargetException
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
                                                                                                    Caused by: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                                                                                                    	at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1994)
                                                                                                    	at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
                                                                                                    	at java.io.FileInputStream.finalize(FileInputStream.java:508)
                                                                                                    	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:339)
                                                                                                    	at java.lang.Daemons$FinalizerDaemon.processReference(Daemons.java:324)
                                                                                                    	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:300)
                                                                                                    	at java.lang.Daemons$Daemon.run(Daemons.java:145)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    Caused by: java.lang.Throwable: Explicit termination method 'close' not called
                                                                                                    	at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
                                                                                                    	at dalvik.system.CloseGuard.open(CloseGuard.java:257)
                                                                                                    	at java.io.FileInputStream.<init>(FileInputStream.java:176)
                                                                                                    	at tech.relaycorp.gateway.data.disk.DiskMessageOperations$readMessage$2.invoke(DiskMessageOperations.kt:39)
                                                                                                    	at tech.relaycorp.gateway.data.disk.DiskMessageOperations$readMessage$2.invoke(DiskMessageOperations.kt:39)
                                                                                                    	at tech.relaycorp.gateway.domain.endpoint.CollectParcels.getInputStream(CollectParcels.kt:70)
                                                                                                    	at tech.relaycorp.gateway.domain.endpoint.CollectParcels.access$getInputStream(CollectParcels.kt:24)
                                                                                                    	at tech.relaycorp.gateway.domain.endpoint.CollectParcels$getInputStream$1.invokeSuspend(Unknown Source:19)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                    	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:684)
2024-01-10 17:17:40.555 19717-19776 AndroidRuntime          pid-19717                            E  FATAL EXCEPTION: DefaultDispatcher-worker-4
                                                                                                    Process: tech.relaycorp.gateway, PID: 19717
                                                                                                    java.lang.IllegalStateException: Flow exception transparency is violated:
                                                                                                        Previous 'emit' call has thrown exception java.io.EOFException, but then emission attempt of value 'tech.relaycorp.relaynet.bindings.pdc.ParcelCollection@cc25341' has been detected.
                                                                                                        Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
                                                                                                        For a more detailed explanation, please refer to Flow documentation.
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.exceptionTransparencyViolated(SafeCollector.kt:140)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:104)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:83)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient.collectAndAckParcels(PoWebClient.kt:253)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient.access$collectAndAckParcels(PoWebClient.kt:74)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient$collectAndAckParcels$1.invokeSuspend(Unknown Source:19)
                                                                                                    	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:684)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@6ec1640, Dispatchers.IO]
2024-01-10 17:19:19.499 20319-20349 AndroidRuntime          pid-20319                            E  FATAL EXCEPTION: DefaultDispatcher-worker-4
                                                                                                    Process: tech.relaycorp.gateway, PID: 20319
                                                                                                    java.lang.IllegalStateException: Flow exception transparency is violated:
                                                                                                        Previous 'emit' call has thrown exception java.io.EOFException, but then emission attempt of value 'tech.relaycorp.relaynet.bindings.pdc.ParcelCollection@670b7d4' has been detected.
                                                                                                        Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
                                                                                                        For a more detailed explanation, please refer to Flow documentation.
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.exceptionTransparencyViolated(SafeCollector.kt:140)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:104)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:83)
                                                                                                    	at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient.collectAndAckParcels(PoWebClient.kt:253)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient.access$collectAndAckParcels(PoWebClient.kt:74)
                                                                                                    	at tech.relaycorp.poweb.PoWebClient$collectAndAckParcels$1.invokeSuspend(Unknown Source:19)
                                                                                                    	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:684)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@55eb61f, Dispatchers.IO]

@gnarea gnarea added the bug Something isn't working label Jan 10, 2024
@gnarea gnarea moved this to Todo in Android maintenance Jan 10, 2024
@sdsantos
Copy link
Collaborator

@gnarea That resembles the issue fixed with #307 and it even points to the old line count. Just checked and we are still using a Gateway without the fix. Here's a PR to take care of that: relaycorp/relaynet-gateway-android#727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants