From ff97d2eb35defe9c87f27ff5d54d5d5cce2cdb7e Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 20 Jan 2017 08:54:20 +0100 Subject: [PATCH] Make BlockContactsIQProvider idiomatic The jids list doesn't have to be lazy initialized, because every IQ of that type is guaranteed to contain at least one JID. Also use ParserUtils.getJidAttribute(). --- .../blocking/provider/BlockContactsIQProvider.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/provider/BlockContactsIQProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/provider/BlockContactsIQProvider.java index ad45f5c4b..5e443c4c7 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/provider/BlockContactsIQProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/provider/BlockContactsIQProvider.java @@ -20,9 +20,9 @@ import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.provider.IQProvider; +import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smackx.blocking.element.BlockContactsIQ; import org.jxmpp.jid.Jid; -import org.jxmpp.jid.impl.JidCreate; import org.xmlpull.v1.XmlPullParser; /** @@ -36,7 +36,7 @@ public class BlockContactsIQProvider extends IQProvider { @Override public BlockContactsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { - List jids = null; + List jids = new ArrayList<>(); outerloop: while (true) { int eventType = parser.next(); @@ -45,10 +45,8 @@ public class BlockContactsIQProvider extends IQProvider { case XmlPullParser.START_TAG: if (parser.getName().equals("item")) { - if (jids == null) { - jids = new ArrayList<>(); - } - jids.add(JidCreate.from(parser.getAttributeValue("", "jid"))); + Jid jid = ParserUtils.getJidAttribute(parser); + jids.add(jid); } break;