diff --git a/gradle/changelog/jaxb_context_creation.yaml b/gradle/changelog/jaxb_context_creation.yaml new file mode 100644 index 0000000000..d38b6b1ef0 --- /dev/null +++ b/gradle/changelog/jaxb_context_creation.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Concurrent modification exception in JAXB stores diff --git a/scm-dao-xml/src/main/java/sonia/scm/store/TypedStoreContext.java b/scm-dao-xml/src/main/java/sonia/scm/store/TypedStoreContext.java index 81183cd5db..f3dde1026c 100644 --- a/scm-dao-xml/src/main/java/sonia/scm/store/TypedStoreContext.java +++ b/scm-dao-xml/src/main/java/sonia/scm/store/TypedStoreContext.java @@ -48,8 +48,11 @@ final class TypedStoreContext { } static TypedStoreContext of(TypedStoreParameters 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 JAXBContext createJaxbContext(TypedStoreParameters parameters) {