Richard Hernandez created FELIX-6318:
----------------------------------------

             Summary: Tiny thread-safety bug in BundleWiringImpl
                 Key: FELIX-6318
                 URL: https://issues.apache.org/jira/browse/FELIX-6318
             Project: Felix
          Issue Type: Bug
            Reporter: Richard Hernandez


In BundleWiringImple::getClassLoaderInternal, you're using double-checked 
locking to access the field m_classLoader. However, you're not using it 
entirely correctly. The current code assigns the volatile field to a local 
variable, null-checks the volatile field, and returns the local variable if the 
second read of the volatile field is not null. While highly improbable, it's 
possible for the first read of the volatile variable to be null and the second 
read to not be. This would cause `BundleWiringImpl::getClassLoader` to return 
null.

 

See 
https://github.com/apache/felix-dev/blob/master/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java#L713-L717



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to