jgrassel commented on pull request #64:
URL: https://github.com/apache/openjpa/pull/64#issuecomment-657699740


   True, OpenLiberty creates the EMF during application start (it has to, in 
order to register the Class Transformer [with the application classloader] 
before any of the persistent capable classes are loaded), but the 
transformation is invoked when the class is first loaded, which can happen at 
any time after the transformer has been registered.  In the customer scenario, 
two concurrent threads triggered a classload on the same application 
classloader.  Before the classloader perf-update, one thread would secure a 
lock on the classloader, while the second thread would get blocked, the class 
that it requested would be enhanced, and then it would unlock the classloader, 
which then the other thread would get its lock.
   
   Now, both threads can concurrently request a class load without one being 
blocked, so both can enter the transformer (enhancer) and the same time.  One 
thread sets the `_transforming` boolean, and while that thread is doing its 
transforming work, the other thread sees that `_transforming` has been set, 
assumes that this is a reentrant call(x), and returns null -- meaning don't 
transform the class.  So the second thread's transform request does not happen, 
and the class is loaded untransformed, and thus cannot be used by openjpa.
   
   (x) - The `_transforming` field was to prevent reentrancy which, in the days 
of single-threaded access, was assumed to be only possible by the thread that 
had the lock on the classloader, and during the transform, a classload occurred 
while in the transform method body and that classload (an openjpa library class 
is the only possibility at this point, it wouldn't be a PC-type) is being 
performed by the classloader that has the enhancer registered to it.  Since it 
was safe to assume that a reentrant call to the enhancer could only be an 
openjpa library type, that would never be enhanced, so just return null instead 
of going through the effort spent to check the type against the persistence 
unit's PC-type membership list.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to