Java

Java

Made by DeepSource

IllegalMonitorStateExceptions should not be handled JAVA-S0040

Anti-pattern
Critical

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