Skip to content

Commit 9e503d8

Browse files
laurentschoelenslukasj
authored andcommitted
[#1726] build xmlNsCache as local function var before setting as class var
fixes ConcurrentModificationException if 2 threads works in the map fixes access to incomplete - building xmlNsCache if second thread access map when first builds it
1 parent 118904e commit 9e503d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jaxb-ri/runtime/impl/src/main/java/org/glassfish/jaxb/runtime/v2/model/impl/TypeInfoSetImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2025 Contributors to the Eclipse Foundation. All rights reserved.
34
*
45
* This program and the accompanying materials are made available under the
56
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -287,7 +288,7 @@ public Iterable<? extends ElementInfoImpl<T,C,F,M>> getAllElements() {
287288
@Override
288289
public Map<String,String> getXmlNs(String namespaceUri) {
289290
if(xmlNsCache==null) {
290-
xmlNsCache = new HashMap<>();
291+
Map<String, Map<String,String>> xmlNsCache = new HashMap<>();
291292

292293
for (ClassInfoImpl<T, C, F, M> ci : beans().values()) {
293294
XmlSchema xs = reader.getPackageAnnotation( XmlSchema.class, ci.getClazz(), null );
@@ -301,6 +302,8 @@ public Map<String,String> getXmlNs(String namespaceUri) {
301302
m.put(xns.prefix(),xns.namespaceURI());
302303
}
303304
}
305+
306+
this.xmlNsCache = xmlNsCache;
304307
}
305308

306309
Map<String,String> r = xmlNsCache.get(namespaceUri);

0 commit comments

Comments
 (0)