File tree 2 files changed +19
-9
lines changed
main/java/com/fasterxml/jackson/dataformat/xml/deser
test/java/com/fasterxml/jackson/dataformat/xml/deser
2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -371,21 +371,23 @@ private final int _next() throws XMLStreamException
371
371
372
372
private final String _collectUntilTag () throws XMLStreamException
373
373
{
374
- String text = null ;
374
+ if (_xmlReader .isEmptyElement ()) {
375
+ _xmlReader .next ();
376
+ return null ;
377
+ }
378
+
379
+ StringBuilder text = new StringBuilder ();
380
+
375
381
while (true ) {
376
382
switch (_xmlReader .next ()) {
377
383
case XMLStreamConstants .START_ELEMENT :
378
384
case XMLStreamConstants .END_ELEMENT :
379
385
case XMLStreamConstants .END_DOCUMENT :
380
- return text ;
381
- // note: SPACE is ignorable (and seldom seen), not to be included
386
+ return text . toString () ;
387
+ // note: SPACE is ignorable (and seldom seen), not to be included
382
388
case XMLStreamConstants .CHARACTERS :
383
389
case XMLStreamConstants .CDATA :
384
- if (text == null ) {
385
- text = _xmlReader .getText ();
386
- } else { // can be optimized in future, if need be:
387
- text += _xmlReader .getText ();
388
- }
390
+ text .append (_xmlReader .getText ());
389
391
break ;
390
392
default :
391
393
// any other type (proc instr, comment etc) is just ignored
Original file line number Diff line number Diff line change 1
- package com .fasterxml .jackson .dataformat .xml .failing ;
1
+ package com .fasterxml .jackson .dataformat .xml .deser ;
2
2
3
3
import java .util .ArrayList ;
4
4
import java .util .List ;
@@ -40,6 +40,14 @@ public void testEmptyString162() throws Exception
40
40
assertEquals ("" , name .last );
41
41
}
42
42
43
+ public void testEmptyElement () throws Exception
44
+ {
45
+ Name name = MAPPER .readValue ("<name><first/><last></last></name>" , Name .class );
46
+ assertNotNull (name );
47
+ assertNull (name .first );
48
+ assertEquals ("" , name .last );
49
+ }
50
+
43
51
public void testEmptyStringElement () throws Exception
44
52
{
45
53
// then with empty element
You can’t perform that action at this time.
0 commit comments