@@ -639,11 +639,7 @@ public JsonToken nextToken() throws IOException
639
639
// we had an empty String (or all white space), and we are
640
640
// deserializing an array, we better hide the empty text.
641
641
// Also: must skip following END_ELEMENT
642
- try {
643
- _xmlTokens .skipEndElement ();
644
- } catch (XMLStreamException e ) {
645
- StaxUtil .throwAsParseException (e , this );
646
- }
642
+ _skipEndElement ();
647
643
if (_parsingContext .inArray ()) {
648
644
if (XmlTokenStream ._allWs (_currText )) {
649
645
// 06-Jan-2015, tatu: as per [dataformat-xml#180], need to
@@ -793,11 +789,7 @@ public String nextTextValue() throws IOException
793
789
if (_mayBeLeaf ) {
794
790
_mayBeLeaf = false ;
795
791
// Also: must skip following END_ELEMENT
796
- try {
797
- _xmlTokens .skipEndElement ();
798
- } catch (XMLStreamException e ) {
799
- StaxUtil .throwAsParseException (e , this );
800
- }
792
+ _skipEndElement ();
801
793
// NOTE: this is different from nextToken() -- NO work-around
802
794
// for otherwise empty List/array
803
795
// 13-May-2020, tatu: [dataformat-xml#397]: advance `index`
@@ -894,11 +886,7 @@ public String getValueAsString(String defValue) throws IOException
894
886
_currToken = JsonToken .VALUE_STRING ;
895
887
_nextToken = null ;
896
888
// One more thing: must explicitly skip the END_OBJECT that would follow
897
- try {
898
- _xmlTokens .skipEndElement ();
899
- } catch (XMLStreamException e ) {
900
- StaxUtil .throwAsParseException (e , this );
901
- }
889
+ _skipEndElement ();
902
890
return (_currText = str );
903
891
}
904
892
} catch (XMLStreamException e ) {
@@ -1094,7 +1082,17 @@ protected ByteArrayBuilder _getByteArrayBuilder()
1094
1082
return _byteArrayBuilder ;
1095
1083
}
1096
1084
1097
- private <T > T _internalErrorUnknownToken (Object token ) {
1085
+ private <T > T _internalErrorUnknownToken (Object token ) {
1098
1086
throw new IllegalStateException ("Internal error: unrecognized XmlTokenStream token: " +token );
1099
1087
}
1088
+
1089
+ protected void _skipEndElement () throws IOException {
1090
+ try {
1091
+ _xmlTokens .skipEndElement ();
1092
+ } catch (XMLStreamException e ) {
1093
+ StaxUtil .throwAsParseException (e , this );
1094
+ } catch (Exception e ) {
1095
+ throw new JsonParseException (this , e .getMessage (), e );
1096
+ }
1097
+ }
1100
1098
}
0 commit comments