IllegalMonitorStateException
s should not be handled 86 synchronized (LOCK) {
87 try {
88 getC().wait();
89 } catch (InterruptedException | IllegalMonitorStateException e) { 90 e.printStackTrace();
91 }
92 waitForLock(prevDone); // Wait for access to the list...
Description
IllegalMonitorStateException
is generally only thrown in case of a design flaw in your code (calling wait
or notify
on an object you do not hold a lock on).
Handling such exceptions instead of diagnosing the underlying issue could lead to more bugs in the long run.
Do not attempt to catch and handle IllegalMonitorStateException
. Instead, diagnose the reason for the exception's occurrence and fix the issue.
References
- Spotbugs - IMSE_DONT_CATCH_IMSE