<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>findbugs detects a problem in the following code:</div><div><br></div><div><div> public void clear() {</div><div> // This is expensive...</div><div> // lock all segments</div><div> for (Segment s : segments) s.lock();</div><div> try {</div><div> for (Segment s : segments) s.locklessClear();</div><div> initLinks();</div><div> } finally {</div><div> for (Segment s : segments) s.unlock();</div><div> }</div><div> }</div><div><br></div><div><br></div><div>the general description of the issue is:</div><div><h1> Method does not release lock on all paths
</h1><p>
This method acquires a JSR-166 (<code>java.util.concurrent</code>) lock,
but does not release it on all paths out of the method. In general, the
correct idiom for using a JSR-166 lock is:
</p>
<pre> Lock l = ...;
l.lock();
try {
// do something
} finally {
l.unlock();
}</pre><pre><br></pre><pre>In my eyes the code is okay, am I missing something?</pre><pre><br></pre><pre>Cheers,</pre><pre>Mircea</pre>
</div></div></body></html>