[jboss-as7-dev] thread safety and AS Service implementations...
Scott Marlow
smarlow at redhat.com
Tue Aug 16 19:53:30 EDT 2011
I would like to get agreement on whether we still need to protect
Service instance variables.
From reading the javadoc in the org.jboss.msc.service.Service class,
mutable instance variables (in Service implementations) need their own
thread safety protection.
I had a mutable object reference in class PersistenceUnitService that is
set in the Service start method and cleared in stop(). Someone reported
a NPE caused by the same mutable object reference, so I think we need to
guard against this pattern elsewhere most likely (forum post about NPE
http://community.jboss.org/message/621316).
https://github.com/scottmarlow/jboss-as/commit/c0f05311680cb936fb1abcb7391d2054e16144c5
changes the variable to be volatile. The down side is that the object
reference won't be cached.
I don't know for sure, that the above code change will fix the NPE, just
seems likely to me.
Scott
More information about the jboss-as7-dev
mailing list