You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/09/01 15:01:21 UTC
[GitHub] [incubator-druid] leventov opened a new issue #8449: Make
IntelliJ's inspection "Lock acquired but not safely unlocked" a error
leventov opened a new issue #8449: Make IntelliJ's inspection "Lock acquired but not safely unlocked" a error
URL: https://github.com/apache/incubator-druid/issues/8449
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
```java
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
```java
final Lock writeLock = startStopSync.writeLock();
writeLock.lock();
```
A little more serious violations are in several classes where:
- There are some statements between `lock()` method call and the beginning of the `try {}` block: exceptions in these statements may lead to a dangling lock.
- `lockInterruptibly()` is called within the `try {}` block, rather than before it: if the locking is interrupted, an attempt to unlock in the `finally {}` block will lead to an `IllegalMonitorStateException` (at best), masking the real problem.
- `fullyLock()` and `fullyUnlock()` in `BytesBoundedLinkedQueue` should be annotated `@LockMethod({"takeLock", "putLock"})` and `@UnlockMethod({"takeLock", "putLock"})`, respectively.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org