6

During debugging of Android app, sometimes InterruptedException occurs and crashes the app. I've been able to set a break-point on default exception handler, but call stack is not informative.

at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1991)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2025)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1048)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:776)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:820)

What is telling is that the interrupted thread is always RxCachedThreadScheduler-4 (or some other number)

What would be a systematic approach towards finding the root cause of the exception?

Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
clearpath
  • 916
  • 8
  • 24
  • The stacktrace should have a location within your code where you use blocking code. Is Retrofit involved? – akarnokd Jul 19 '18 at 20:52
  • @akarnokd there is no mention of my code – clearpath Jul 24 '18 at 12:14
  • [Set a breakpoint](https://stackoverflow.com/a/28862538/61158) for `InterruptedException` and step through to see where it is and what it affects. Generally though, there is little chance we could help you without seeing the code. – akarnokd Jul 24 '18 at 12:18
  • Do you use any `sleep()` , `join()` or `wait()` method ??? Where ? – Omid.N Aug 03 '18 at 08:25

2 Answers2

4

Set breakpoint at the method Thread::interrupt and catch the offender. If you think that this interruption should not happen, and you cannot switch off the call which interrupts your thread, then you can override Thread::interrupt in your thread implementation, and force the the thread pool to use your implementation by providing your own ThreadFactory.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38
2

It looks like the crash is happening from a third party code package, you should post your issue with the source project as well for additional help. Please post any code related to how you use this package to help troubleshoot too. Make sure you're using the latest version of this package in case they already fixed this issue. The stack trace isn't very helpful because the other project is launching threads and the crash happens from within one of their threads. Likely, you're not using the package as intended or there is a bug in it that they need to fix.

https://github.com/ReactiveX/RxJava
CodeSmith
  • 1,621
  • 1
  • 13
  • 31