Skip to content

Commit 50282e0

Browse files
committed
Further cleanup wrt #531
1 parent 5ea4f3b commit 50282e0

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected XmlFactory(XmlFactoryBuilder b)
165165
_cfgNameForTextElement = b.nameForTextElement();
166166
_xmlInputFactory = b.xmlInputFactory();
167167
_xmlOutputFactory = b.xmlOutputFactory();
168-
_nameProcessor = b.xmlTagProcessor();
168+
_nameProcessor = b.xmlNameProcessor();
169169
_initFactories(_xmlInputFactory, _xmlOutputFactory);
170170
}
171171

@@ -336,11 +336,11 @@ public int getFormatGeneratorFeatures() {
336336
return _xmlGeneratorFeatures;
337337
}
338338

339-
public XmlNameProcessor getXmlTagProcessor() {
339+
public XmlNameProcessor getXmlNameProcessor() {
340340
return _nameProcessor;
341341
}
342342

343-
public void setXmlTagProcessor(XmlNameProcessor processor) {
343+
public void setXmlNameProcessor(XmlNameProcessor processor) {
344344
_nameProcessor = processor;
345345
}
346346

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected ClassLoader staxClassLoader() {
142142
getClass().getClassLoader() : _classLoaderForStax;
143143
}
144144

145-
public XmlNameProcessor xmlTagProcessor() {
145+
public XmlNameProcessor xmlNameProcessor() {
146146
return _nameProcessor;
147147
}
148148

@@ -270,7 +270,7 @@ public XmlFactoryBuilder staxClassLoader(ClassLoader cl) {
270270
/**
271271
* @since 2.14
272272
*/
273-
public XmlFactoryBuilder xmlTagProcessor(XmlNameProcessor nameProcessor) {
273+
public XmlFactoryBuilder xmlNameProcessor(XmlNameProcessor nameProcessor) {
274274
_nameProcessor = nameProcessor;
275275
return _this();
276276
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public XmlMapper setDefaultUseWrapper(boolean state) {
292292
* @since 2.14
293293
*/
294294
public void setXmlNameProcessor(XmlNameProcessor processor) {
295-
((XmlFactory)_jsonFactory).setXmlTagProcessor(processor);
295+
((XmlFactory)_jsonFactory).setXmlNameProcessor(processor);
296296
}
297297

298298
/*

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private XmlNameProcessors() {
4040
* @since 2.14
4141
*/
4242
public static XmlNameProcessor newPassthroughProcessor() {
43-
return new PassthroughTagProcessor();
43+
return new PassthroughProcessor();
4444
}
4545

4646
/**
@@ -157,10 +157,10 @@ public static XmlNameProcessor newAlwaysOnBase64Processor() {
157157
return new AlwaysOnBase64NameProcessor();
158158
}
159159

160-
static class PassthroughTagProcessor implements XmlNameProcessor {
160+
static class PassthroughProcessor implements XmlNameProcessor {
161161
private static final long serialVersionUID = 1L;
162162

163-
public PassthroughTagProcessor() { }
163+
public PassthroughProcessor() { }
164164

165165
@Override
166166
public void encodeName(XmlName name) { }

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NoArgCtorDeser491Test.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@
1818
* token (for consistency with how XML is mapper to tokens); this leads to deserialization
1919
* attempting to use "empty Object" construction which expects availability of the
2020
* default constructor.
21-
* To resolve the issue there are at least two possible ways:
22-
*<ul>
23-
* <li>Try to make root element appears as START-OBJECT/END-OBJECT sequence instead of VALUE_STRING
24-
* </li>
25-
* <li>Change {@code StdDeserializer} (from jackson-databind) to allow use of "properties-based"
26-
* Creator as well -- passing equivalent of all-absent values. This could either be for all
27-
* content, or just for specific formats (using a {@code StreamReadFeature} to detect).
28-
* </li>
29-
*</ul>
30-
* Either approach could work, although former could cause other kinds of regression.
21+
*<p>
22+
* Jackson 2.14 solved this issue by reverting earlier changes so that empty element
23+
* is exposed as simple START_OBJECT/END_OBJECT sequence (that is, empty Object).
24+
* Use cases where (non-empty) element needs to map to Scalar types is now handled
25+
* with mechanism introduced in 2.13.
3126
*/
3227
public class NoArgCtorDeser491Test extends XmlTestBase
3328
{
@@ -101,12 +96,16 @@ public void test_empty_Problem_JSON_deserialization() throws Exception
10196
public void test_empty_Problem_XML_deserialization() throws Exception
10297
{
10398
Problem problem = XML_MAPPER.readValue(
104-
// This WOULD work:
105-
// "<problem><status>500</status></problem>",
106-
// but not missing
10799
"<problem />",
108100
Problem.class);
109101
assertEquals(Problem.DEFAULT_TYPE, problem.getType());
110102
assertEquals(Problem.DEFAULT_STATUS, problem.getStatus());
103+
104+
// Also ensure variations of empty do not vary
105+
problem = XML_MAPPER.readValue(
106+
"<problem>\n</problem>",
107+
Problem.class);
108+
assertEquals(Problem.DEFAULT_TYPE, problem.getType());
109+
assertEquals(Problem.DEFAULT_STATUS, problem.getStatus());
111110
}
112111
}

0 commit comments

Comments
 (0)