Invoke Thread.currentThread().interrupt() whenever an InterruptException is caught
Log the interrupt in places where the exception was just swallowed
Add a finally to VehicleManager where the InterruptException was to make to unlock mRemoteBoundLock
Notes
By searching online, found out that a thread should handle the exception in this way as to set it's interrupt flag. This is just to let high level methods know that the thread may terminate and allow the higher level to handle it if needed. As a general rule, we shouldn't just swallow.
This is done to keep state.
When you catch the InterruptException and swallow it, you essentially prevent any higher level methods/thread groups from noticing the interrupt. Which may cause problems.
By calling Thread.currentThread().interrupt(), you set the interrupt flag of the thread, so higher level interrupt handlers will notice it and can handle it appropriately.
Only code that implements a thread's interruption policy may swallow an interruption request.
General-purpose task and library code should never swallow interruption requests.
Changes
Thread.currentThread().interrupt()
whenever anInterruptException
is caughtVehicleManager
where theInterruptException
was to make to unlockmRemoteBoundLock
Notes
By searching online, found out that a thread should handle the exception in this way as to set it's interrupt flag. This is just to let high level methods know that the thread may terminate and allow the higher level to handle it if needed. As a general rule, we shouldn't just swallow.
Reference