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

Andrew Dinn adinn at redhat.com
Thu Jan 24 10:17:38 EST 2008


Andrew Dinn wrote:
> 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.

Ok, I know I'm replying to my own reply to my reply but I'll just note 
that my initial analysis was not 'obviously' wrong. It's actually more 
subtle than that as it might just be right depending upon whether the 
value of field header is refetched if a yield occurs between execution 
of 'e = header.next' and 'e != header'. This may or may not happen at a 
compiler's whim since the code does not employ any synchronization.

Anyway, a concurrent remove is a much more likely culprit.

regards,


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



More information about the jboss-development mailing list