rzo1 opened a new pull request, #309:
URL: https://github.com/apache/openjpa/pull/309

   [OPENJPA-3081](https://issues.apache.org/jira/browse/OPENJPA-3081): with 
`openjpa.RuntimeUnenhancedClasses=supported`, the runtime subclasses of 
unenhanced entities are only created and registered in `PCRegistry` when a 
factory creates its first broker. On a fresh factory, before any 
`EntityManager`, `getMetamodel()`, `getCriteriaBuilder()` and 
`getNamedEntityGraphs()` threw `MetaDataException: ... has not been enhanced`, 
and `PersistenceUnitUtil.getIdentifier()` threw `IllegalArgumentException`. 
Whether it worked depended on what ran before in the same JVM (`PCRegistry` is 
static); found through random test order on #305.
   
   **Fix**
   - `AbstractBrokerFactory.loadPersistentTypes`: the first load and 
preparation of the types runs under the factory lock with a double check, and 
the loaded flag is published only after `prepareUnenhancedClasses` ran, so 
concurrent first callers neither prepare the types twice nor see them half 
prepared.
   - `EntityManagerFactoryImpl`: `getMetamodel()` (and through it 
`getCriteriaBuilder()` / `getNamedEntityGraphs()`) and `getIdentifier()` run 
that same preparation before they need the types, once per factory, only with 
`RuntimeUnenhancedClasses=supported` and never on a closed factory.
   
   Enhanced classes and the `unsupported` / `warn` modes are unchanged; the 
change only turns an exception into success, so no compatibility option.
   
   **Tests:** new `TestFactoryMetaDataOfUnenhancedTypes` (each method with its 
own unenhanced entity that no other test uses, asserted unregistered before the 
call): metamodel, criteria builder, entity graphs and identifier before the 
first `EntityManager`, identifier after `close()` (still 
`IllegalArgumentException`), preparation exactly once, and concurrent first 
callers. Fails without the fix (4 of the original tests error). 
`openjpa-kernel` and `openjpa-persistence` unit tests and the related 
`openjpa-persistence-jdbc` packages pass on Derby.
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to