[
https://issues.apache.org/jira/browse/OPENJPA-2222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Richard Zowalla resolved OPENJPA-2222.
--------------------------------------
Resolution: Fixed
Already fixed on master: 9fa619f94 (on master) removed the shared boolean
_transforming guard that made a second thread return null. transform()
(PCClassFileTransformer.java:116) has no shared guard now, and the opt-in
Reentrant variant uses a per-thread ThreadLocal (line 276). Closing; please
reopen if this still happens with OpenJPA 4.x.
> Concurrency issue with JPA enhancement in Apache Open JPA
> ---------------------------------------------------------
>
> Key: OPENJPA-2222
> URL: https://issues.apache.org/jira/browse/OPENJPA-2222
> Project: OpenJPA
> Issue Type: Bug
> Components: Enhance
> Affects Versions: 2.2.0
> Reporter: Brian DePradine
> Priority: Major
>
> Working Jeremy Bauer, we discovered the following issue:
> I think I've figured out what is causing the transformer to return null in
> some (intermittent) cases. I'm seeing multiple threads [Blueprint Extender:
> # ] calling into the same PCClassFileTransformer. I've pasted the stack for
> thread 1 below. I saw an identical instance for a thread 3 - operating on a
> different persistent class at the same time. This resulted in one of the
> transforms (per transform method below) returned null.
> public byte[] transform(ClassLoader loader, String className,
> Class redef, ProtectionDomain domain, byte[] bytes)
> throws IllegalClassFormatException {
> if (loader == _tmpLoader)
> return null;
> // JDK bug -- OPENJPA-1676
> if (className == null) {
> return null;
> }
> ---------------------
> // prevent re-entrant calls, which can occur if the enhancing
> // loader is used to also load OpenJPA libraries; this is to prevent
> // recursive enhancement attempts for internal openjpa libraries
> if (_transforming)
> return null;
> ---------------------
> _transforming = true;
>
> return transform0(className, redef, bytes);
> }
> Since you use the same transformer on multiple threads we are hitting the
> condition where there is a transform in progress and you are trying to do
> another transform on a separate thread.
> I spent some time looking at the JPA spec to determine what it says about
> transformer concurrency and I can't find anything that says that you
> shouldn't be able to call a transformer in a concurrent manner, hence this
> defect.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)