Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.4.0
-
None
-
None
Description
When using "DynamicDataStructs=true" there is a chance of running into an ClassFormatError due to multiple enhancing of persistent classes:
java.lang.ClassFormatError: Duplicate field name&signature in class file <class-name-strippted>openjpapcdatadatacache
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.7.0_75]
at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[?:1.7.0_75]
at java.lang.ClassLoader.defineClass(ClassLoader.java:643) ~[?:1.7.0_75]
at serp.bytecode.BCClassLoader.findClass(BCClassLoader.java:50) ~[org.apache.servicemix.bundles.serp-1.15.1_1.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[?:1.7.0_75]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[?:1.7.0_75]
at java.lang.Class.forName0(Native Method) ~[?:1.7.0_75]
at java.lang.Class.forName(Class.java:274) ~[?:1.7.0_75]
at org.apache.openjpa.enhance.DynamicStorageGenerator.createFactory(DynamicStorageGenerator.java:169) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.enhance.DynamicStorageGenerator.generateStorage(DynamicStorageGenerator.java:124) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.enhance.PCDataGenerator.generateStorage(PCDataGenerator.java:115) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.enhance.PCDataGenerator.generatePCData(PCDataGenerator.java:92) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.datacache.DataCacheStoreManager.newPCData(DataCacheStoreManager.java:797) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.datacache.DataCacheStoreManager.updateCaches(DataCacheStoreManager.java:144) ~[openjpa-2.4.0.jar:2.4.0]
at org.apache.openjpa.datacache.DataCacheStoreManager.commit(DataCacheStoreManager.java:87) ~[openjpa-2.4.0.jar:2.4.0]
The issue happens if the enhancing hasn't been performed yet and multiple threads concurrently commit a transaction. They will both call PCDataGenerator#generateStorage with the same class. This should be guarded with some kind of synchronisation around the underlying map (containing the enhanced classes). It's hard to provide a test case for this but keeping a breakpoint open in #generateStorage and committing multiple threads will lead to the exception above.