apache / druid

Apache Druid: a high performance real-time analytics database.
https://druid.apache.org/
Apache License 2.0
13.38k stars 3.67k forks source link

Make IntelliJ's inspection "Lock acquired but not safely unlocked" a error #8449

Open leventov opened 5 years ago

leventov commented 5 years ago

There are about a dozen violations of this rule in the codebase. Most of them look relatively benign, though they are still antipatterns, for example, in NamespaceLookupExtractorFactory, where code

final Lock writeLock = startStopSync.writeLock();
try {
  writeLock.lockInterruptibly();
}
catch (InterruptedException e) {
  throw new RuntimeException(e);
}

Doesn't make sense to me. I think it should be replaced with simple

final Lock writeLock = startStopSync.writeLock();
writeLock.lock();

A little more serious violations are in several classes where:

leventov commented 5 years ago

Related: https://youtrack.jetbrains.com/issue/IDEA-221767