Findbugs and locks?
- From: Knute Johnson <nospam@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 22:06:16 -0700
Findbugs gives the warning "Method does not release lock on all exception paths" on a method like the one below. Could it be because the lock is from an array of locks and it can't determine which? Or is it because you could put code outside of the try/finally block that could leave without unlocking the lock? Any other ideas? It can't leave the method without unlocking can it?
ReentrantReadWriteLock lock[] = new ReentrantReadWriteLock[5];
for (int i=0; i<lock.length; i++)
lock[i] = new ReentrantReadWriteLock();
static void method(int n) throws IOException {
lock[n].writeLock().lock();
try {
// do some disk I/O
} finally {
lock[n].writeLock().unlock();
}
}
Thanks,
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
.
- Follow-Ups:
- Re: Findbugs and locks?
- From: Jeff Higgins
- Re: Findbugs and locks?
- Prev by Date: Re: installing jdk6 on jdk5
- Next by Date: Re: Findbugs and locks?
- Previous by thread: import statement
- Next by thread: Re: Findbugs and locks?
- Index(es):
Relevant Pages
|