Findbugs and locks?



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
.



Relevant Pages

  • Re: Access problems at MERSTHAM
    ... they have also changed the "lock". ... Alan, AKA The Bogeyman, Aka Alan. ... Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (uk.rec.subterranea)
  • RE: A button question!
    ... (as opposed to locking them by default then unlocking them if they are new) ... Private Sub NewRec_Click ... "Andy Hull" wrote: ... "lock" the fields. ...
    (microsoft.public.access.forms)
  • Re: Snow Leopard Time Machine wont stay locked
    ... unlocking. ... How does one make the lock "stick"? ... When I go to the Time Machine pref pane, ... Security pref panes setting are locked, ...
    (comp.sys.mac.apps)
  • Re: threaded queue - and cream cheese
    ... the queue is empty and release it when adding to the queue. ... unlocking an unlocked lock, and occaisionally there will be a message ... Threading, and in particular thread synchronization, is not the ...
    (comp.sys.mac.programmer.help)
  • Re: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock()
    ... you only need to do the reverse unlock ... if you do it after unlocking the outer lock? ...
    (Linux-Kernel)