[infinispan-dev] findbugs found issue

David M. Lloyd david.lloyd at redhat.com
Thu Sep 3 10:38:14 EDT 2009


On 09/03/2009 03:55 AM, Mircea Markus wrote:
> Hi,
> 
> findbugs detects a problem in the following code:
> 
>    public void clear() {
>       // This is expensive...
>       // lock all segments
>       for (Segment s : segments) s.lock();
>       try {
>          for (Segment s : segments) s.locklessClear();
>          initLinks();
>       } finally {
>          for (Segment s : segments) s.unlock();
>       }
>    }
> In my eyes the code is okay, am I missing something?

Yes - if one of the unlocks fail, the subsequent locks will not be 
released.  If one of the locks fail, none of the acquired locks will be 
released.

- DML




More information about the infinispan-dev mailing list