IllegalMonitorStateException
s should not be handled 88 synchronized (LOCK) {
89 try {
90 getC().wait();
91 } catch (InterruptedException | IllegalMonitorStateException e) { 92 e.printStackTrace();
93 }
94 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