Skip to content

Commit 597a043

Browse files
authored
Fix copy-on-write consistency in updateProperties isText path (#834)
1 parent 8ce6c8d commit 597a043

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/tools/jackson/dataformat/xml/deser/XmlBeanDeserializerModifier.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,18 @@ public List<BeanPropertyDefinition> updateProperties(DeserializationConfig confi
4444
if (acc == null) {
4545
continue;
4646
}
47-
/* First: handle "as text"? Such properties
48-
* are exposed as values of 'unnamed' fields; so one way to
49-
* map them is to rename property to have name ""... (and
50-
* hope this does not break other parts...)
51-
*/
47+
// First: handle "as text"? Such properties are exposed as values of 'unnamed'
48+
// properties; so one way to map them is to rename property to have special
49+
// name (and hope this does not break other parts...)
5250
Boolean b = AnnotationUtil.findIsTextAnnotation(config, intr, acc);
5351
if (b != null && b.booleanValue()) {
54-
// unwrapped properties will appear as 'unnamed' (empty String)
5552
BeanPropertyDefinition newProp = prop.withSimpleName(_cfgNameForTextValue);
5653
if (newProp != prop) {
54+
// 24-Mar-2026, tatu: Create defensive copy
55+
if (changed == 0) {
56+
propDefs = new ArrayList<>(propDefs);
57+
}
58+
++changed;
5759
propDefs.set(i, newProp);
5860
}
5961
continue;
@@ -67,7 +69,7 @@ public List<BeanPropertyDefinition> updateProperties(DeserializationConfig confi
6769
&& !localName.equals(prop.getName())) {
6870
// make copy-on-write as necessary
6971
if (changed == 0) {
70-
propDefs = new ArrayList<BeanPropertyDefinition>(propDefs);
72+
propDefs = new ArrayList<>(propDefs);
7173
}
7274
++changed;
7375
propDefs.set(i, prop.withSimpleName(localName));

0 commit comments

Comments
 (0)