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

Andrew Dinn adinn at redhat.com
Thu Jan 24 09:18:32 EST 2008


Dimitris Andreadis wrote:

> Digging at the logs (full trace at the bottom) I can see a strange NPE 
> from java.util.LinkedList.contains(Object o), after which various 
> deployments get to fail:
> 
> DEBUG [org.jboss.deployment.SARDeployer] create operation failed for 
> package 
> file:/qa/services/hudson/hudson_workspace/workspace/JBoss-AS-4.2.x-TestSuite-sun15/Branch_4_2/testsuite/output/lib/receivers-arraylist-service.xml 
> 
> java.lang.NullPointerException
>     at java.util.LinkedList.indexOf(LinkedList.java:406)
>     at java.util.LinkedList.contains(LinkedList.java:176)
>     at 
> org.jboss.system.ServiceController.register(ServiceController.java:828)
>     at 
> org.jboss.system.ServiceController.create(ServiceController.java:296)
>     at 
> org.jboss.system.ServiceController.create(ServiceController.java:273)
> 
> This is the ServiceController code trying to add a non-null context, so 
> is this really a JDK bug?

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            }
. . .

If the list is empty at 'e = header.next' then a concurrent insert 
happens before 'e != header' this could mean e is null at 'e.element'. 
This would require a yield test to be placed between the loop 
initializer code and the loop test which is possible depending upon the 
compiler scheme for inserting yield points.

regards,


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



More information about the jboss-development mailing list