@@ -601,11 +601,7 @@ public JsonToken nextToken() throws IOException
601
601
// we had an empty String (or all white space), and we are
602
602
// deserializing an array, we better hide the empty text.
603
603
// Also: must skip following END_ELEMENT
604
- try {
605
- _xmlTokens .skipEndElement ();
606
- } catch (XMLStreamException e ) {
607
- StaxUtil .throwAsParseException (e , this );
608
- }
604
+ _skipEndElement ();
609
605
if (_parsingContext .inArray ()) {
610
606
if (XmlTokenStream ._allWs (_currText )) {
611
607
// 06-Jan-2015, tatu: as per [dataformat-xml#180], need to
@@ -755,11 +751,7 @@ public String nextTextValue() throws IOException
755
751
if (_mayBeLeaf ) {
756
752
_mayBeLeaf = false ;
757
753
// Also: must skip following END_ELEMENT
758
- try {
759
- _xmlTokens .skipEndElement ();
760
- } catch (XMLStreamException e ) {
761
- StaxUtil .throwAsParseException (e , this );
762
- }
754
+ _skipEndElement ();
763
755
// NOTE: this is different from nextToken() -- NO work-around
764
756
// for otherwise empty List/array
765
757
// 13-May-2020, tatu: [dataformat-xml#397]: advance `index`
@@ -856,11 +848,7 @@ public String getValueAsString(String defValue) throws IOException
856
848
_currToken = JsonToken .VALUE_STRING ;
857
849
_nextToken = null ;
858
850
// One more thing: must explicitly skip the END_OBJECT that would follow
859
- try {
860
- _xmlTokens .skipEndElement ();
861
- } catch (XMLStreamException e ) {
862
- StaxUtil .throwAsParseException (e , this );
863
- }
851
+ _skipEndElement ();
864
852
return (_currText = str );
865
853
}
866
854
} catch (XMLStreamException e ) {
@@ -1056,7 +1044,17 @@ protected ByteArrayBuilder _getByteArrayBuilder()
1056
1044
return _byteArrayBuilder ;
1057
1045
}
1058
1046
1059
- private <T > T _internalErrorUnknownToken (Object token ) {
1047
+ private <T > T _internalErrorUnknownToken (Object token ) {
1060
1048
throw new IllegalStateException ("Internal error: unrecognized XmlTokenStream token: " +token );
1061
1049
}
1050
+
1051
+ protected void _skipEndElement () throws IOException {
1052
+ try {
1053
+ _xmlTokens .skipEndElement ();
1054
+ } catch (XMLStreamException e ) {
1055
+ StaxUtil .throwAsParseException (e , this );
1056
+ } catch (Exception e ) {
1057
+ throw new JsonParseException (this , e .getMessage (), e );
1058
+ }
1059
+ }
1062
1060
}
0 commit comments