jgrassel commented on pull request #64: URL: https://github.com/apache/openjpa/pull/64#issuecomment-657775964
@rmannibucau 1. `preload=true` is not enabled by default (at least it is not in the 2.2.x branch.) Therefore the MDR will lazily initialize itself in incrementals that it finds necessary. Also, processing reaches the `_transforming` check before touching the MDR (which yes, has synchronized access, but it is invoked only after `_transforming` is checked and set) 2. The `_transforming` field is there because it is possible for a classloader load to occur while the transform() is being executed, where the second load is an OpenJPA library type (for the scenario where OpenJPA is bundled in the application and thus is being loaded by the application classloader that will call on the enhancer to transform a class before loading it), which when classloader access is synchronized across threads, a reentrant call could be assumed to be this situation. See Marc's commit from 14 years ago: ``` commit f74ac8b6b9f8d6f5c4fdae6798018458687741fc Author: Marc Prud'hommeaux <mprud...@apache.org> 2006-09-29 21:00:40 Committer: Marc Prud'hommeaux <mprud...@apache.org> 2006-09-29 21:00:40 Parent: 1236605135400dd42e4942d25cff310ac304dac0 (removed unneeded imports) Child: e30632b60b26430fe4f95dd3f5a3bd79c4a36f9f (Trying a new approach to automatic enhancement in a container. Might have to revert.) Branches: 2.2.x_debug, 2.2.x_OJ2287, 2.2.x_OJ2790, 2.2.x_TS003776060_PH26967, 2.4.x_OJ2790, currentaccessdiag, DIAG_TS003449484, master, master_OJ2790, OJ2603, OPENJPA_2817_22X, pmr42014_211_788, QueryDebugForCase, trunk, TS000798754, TS001107772, TS001228829_DIAG01, TS001491495, TS002193952_detach_issue, TS002637050_testfix_2.2.x, ibmgit/1.2.x, ibmgit/2.2.x_debug and 71 more branches Prevent reentrant calls to transform() in order to prevent attempts to enhance OpenJPA libraries (for cases where OpenJPA falls under the control of the enhancing class loader). git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@451517 13f79535-47bb-0310-9956-ffa450edef68 ``` However, because now the classloader isn't going to synchronize between threads, we can't make that assumption anymore, hence we need to rely on a marker that is independent of the thread -- a ThreadLocal instead of a boolean. 3. This is an issue within the transformer/enhancer, I do not think shifting the burden of single-transformer entrancy to the application server is the correct solution. ---------------------------------------------------------------- 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