mirror of https://github.com/apache/openjpa.git
ConcurrentModificationException window when MetaDataRepository cache updated
Signed-off-by: Will Dazey <dazeydev.3@gmail.com>
This commit is contained in:
parent
ef98e18480
commit
b27175be87
|
@ -1648,14 +1648,21 @@ public class MetaDataRepository implements PCRegistry.RegisterClassListener, Con
|
||||||
* before other threads attempt to call this method
|
* before other threads attempt to call this method
|
||||||
*/
|
*/
|
||||||
synchronized Class<?>[] processRegisteredClasses(ClassLoader envLoader) {
|
synchronized Class<?>[] processRegisteredClasses(ClassLoader envLoader) {
|
||||||
|
|
||||||
|
Class<?>[] reg;
|
||||||
|
/*Synchronize `_registered` cache to block MetaDataRepository.register() from adding
|
||||||
|
* to the cache while we copy, causing a ConcurrentModificationException
|
||||||
|
*/
|
||||||
|
synchronized (_registered) {
|
||||||
if (_registered.isEmpty()) {
|
if (_registered.isEmpty()) {
|
||||||
return EMPTY_CLASSES;
|
return EMPTY_CLASSES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy into new collection to avoid concurrent mod errors on reentrant
|
// copy into new collection to avoid concurrent mod errors on reentrant
|
||||||
// registrations
|
// registrations
|
||||||
Class<?>[] reg = _registered.toArray(new Class[_registered.size()]);
|
reg = _registered.toArray(new Class[_registered.size()]);
|
||||||
_registered.clear();
|
_registered.clear();
|
||||||
|
}
|
||||||
|
|
||||||
Collection<String> pcNames = getPersistentTypeNames(false, envLoader);
|
Collection<String> pcNames = getPersistentTypeNames(false, envLoader);
|
||||||
Collection<Class<?>> failed = null;
|
Collection<Class<?>> failed = null;
|
||||||
|
|
Loading…
Reference in New Issue