[core] Align behavior of getParserFor(InputStream) and getParserFor(Reader)

Reported-by: Ingo Bauersachs <ingo@jitsi.org>
master
Florian Schmaus 9 months ago
parent cad63bc107
commit 11cc2d8d77
  1. 6
      smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
  2. 2
      smack-extensions/src/test/java/org/jivesoftware/smackx/amp/AMPExtensionTest.java
  3. 1
      smack-extensions/src/test/java/org/jivesoftware/smackx/xhtmlim/provider/XHTMLExtensionProviderTest.java

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2019 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2019-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -76,9 +76,9 @@ public class PacketParserUtils {
return getParserFor(new StringReader(stanza));
}
public static XmlPullParser getParserFor(InputStream inputStream) throws XmlPullParserException {
public static XmlPullParser getParserFor(InputStream inputStream) throws XmlPullParserException, IOException {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
return SmackXmlParser.newXmlParser(inputStreamReader);
return getParserFor(inputStreamReader);
}
public static XmlPullParser getParserFor(Reader reader) throws XmlPullParserException, IOException {

@ -67,7 +67,6 @@ public class AMPExtensionTest {
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(INCORRECT_RECEIVING_STANZA_STREAM);
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
assertEquals(AMPExtension.ELEMENT, parser.getName());
ExtensionElement extension = ampProvider.parse(parser);
@ -85,7 +84,6 @@ public class AMPExtensionTest {
AMPExtensionProvider ampProvider = new AMPExtensionProvider();
XmlPullParser parser = PacketParserUtils.getParserFor(CORRECT_SENDING_STANZA_STREAM);
assertEquals(XmlPullParser.Event.START_ELEMENT, parser.next());
assertEquals(AMPExtension.ELEMENT, parser.getName());
ExtensionElement extension = ampProvider.parse(parser);
assertTrue(extension instanceof AMPExtension);

@ -39,7 +39,6 @@ public class XHTMLExtensionProviderTest {
public void parsesWell() throws IOException, XmlPullParserException {
InputStream inputStream = getClass().getResourceAsStream(XHTML_EXTENSION_SAMPLE_RESOURCE_NAME);
XmlPullParser parser = PacketParserUtils.getParserFor(inputStream);
parser.next();
XHTMLExtensionProvider provider = new XHTMLExtensionProvider();
ExtensionElement extension = provider.parse(parser, parser.getDepth(), null);

Loading…
Cancel
Save