Synchronize jaxb context generation

This commit is contained in:
Rene Pfeuffer
2023-03-09 10:38:56 +01:00
committed by SCM-Manager
parent dda52b8400
commit e74225e168
2 changed files with 7 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Concurrent modification exception in JAXB stores

View File

@@ -48,8 +48,11 @@ final class TypedStoreContext<T> {
}
static <T> TypedStoreContext<T> of(TypedStoreParameters<T> parameters) {
JAXBContext jaxbContext = contextCache.computeIfAbsent(parameters.getType(), type -> createJaxbContext(parameters));
return new TypedStoreContext<>(jaxbContext, parameters);
JAXBContext jaxbContext;
synchronized (contextCache) {
jaxbContext = contextCache.computeIfAbsent(parameters.getType(), type -> createJaxbContext(parameters));
}
return new TypedStoreContext<>(jaxbContext, parameters);
}
private static <T> JAXBContext createJaxbContext(TypedStoreParameters<T> parameters) {