[jboss-dev] Strange java.util.LinkedList.contains() NPE

Andrew Dinn adinn at redhat.com
Thu Jan 24 10:03:14 EST 2008


Andrew Dinn wrote:
> It could be a concurrency bug. The relevant code is
> 
> . . .
> 105            for (Entry e = header.next; e != header; e = e.next) {
> 106                if (o.equals(e.element))
> 107                    return index;
> 108                index++;
> 109            }
> . . .

Oops, first off, apologies for posting an analysis which was obviously 
wrong.

However, I believe a concurrent remove may also cause your problem. The 
remove() method sets the next field of the removed Entry to null. So, if 
the loop above yields at a loop back edge and a concurrent call to 
remove operates on Entry e then you could get the intermittent NPE you 
are seeing.

regards,


Andrew Dinn
-----------



More information about the jboss-development mailing list