Skip to content

Commit 345d2af

Browse files
committed
Merge branch '2.11' into 2.12
2 parents 4ba0626 + 43ddaac commit 345d2af

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

release-notes/VERSION-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Project: jackson-dataformat-xml
3030
#399: Can not deserialize unwrapped list when `@JacksonXmlProperty` localName matches
3131
the parent's localName
3232
(reported by sandboxgod@github)
33+
#404: Make `@JacksonXmlElementWrapper` indicate XML property
3334
3435
2.11.0 (26-Apr-2020)
3536

src/main/java/com/fasterxml/jackson/dataformat/xml/JacksonXmlAnnotationIntrospector.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.fasterxml.jackson.dataformat.xml;
22

3+
import java.lang.annotation.Annotation;
4+
35
import com.fasterxml.jackson.databind.PropertyName;
46
import com.fasterxml.jackson.databind.introspect.*;
57
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
@@ -18,6 +20,13 @@ public class JacksonXmlAnnotationIntrospector
1820
{
1921
private static final long serialVersionUID = 1L;
2022

23+
// @since 2.11.1
24+
@SuppressWarnings("unchecked")
25+
private final static Class<? extends Annotation>[] ANNOTATIONS_TO_INFER_XML_PROP =
26+
(Class<? extends Annotation>[]) new Class<?>[] {
27+
JacksonXmlText.class, JacksonXmlElementWrapper.class
28+
};
29+
2130
/**
2231
* For backwards compatibility with 2.0, the default behavior is
2332
* to assume use of List wrapper if no annotations are used.
@@ -151,7 +160,7 @@ public PropertyName findNameForSerialization(Annotated a)
151160
if (name == null) {
152161
name = super.findNameForSerialization(a);
153162
if (name == null) {
154-
if (a.hasAnnotation(JacksonXmlText.class)) {
163+
if (_hasOneOf(a, ANNOTATIONS_TO_INFER_XML_PROP)) {
155164
return PropertyName.USE_DEFAULT;
156165
}
157166
}
@@ -166,7 +175,7 @@ public PropertyName findNameForDeserialization(Annotated a)
166175
if (name == null) {
167176
name = super.findNameForDeserialization(a);
168177
if (name == null) {
169-
if (a.hasAnnotation(JacksonXmlText.class)) {
178+
if (_hasOneOf(a, ANNOTATIONS_TO_INFER_XML_PROP)) {
170179
return PropertyName.USE_DEFAULT;
171180
}
172181
}

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UntypedListSerialization8Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public TypedListBean() {
3535
list = l;
3636
}
3737
}
38-
38+
3939
/*
4040
/**********************************************************
4141
/* Unit tests
4242
/**********************************************************
4343
*/
4444

45-
private final XmlMapper MAPPER = new XmlMapper();
45+
private final XmlMapper MAPPER = newMapper();
4646

4747
/*
4848
* For [dataformat-xml#8] -- Will not use wrapping, if type is not statically known

src/test/java/com/fasterxml/jackson/dataformat/xml/ser/EmptyPolymorphicTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ static class EmptyProxy implements Proxy { }
3232
/* Test methods
3333
/**********************************************************
3434
*/
35-
36-
protected XmlMapper MAPPER = new XmlMapper();
37-
35+
36+
private final XmlMapper MAPPER = newMapper();
37+
3838
public void testEmpty() throws Exception
3939
{
4040
String xml = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(new Data("Foobar"));

0 commit comments

Comments
 (0)