From 19f96d2c401a1777375825f48d5efacc974832a4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 20 Feb 2015 12:15:00 +0100 Subject: [PATCH] Avoid duplicate provider lookup in ItemProvider This also fixes a programming error, since it could be possible that the provider was removed between the lookup and the usage. --- .../jivesoftware/smackx/pubsub/provider/ItemProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index 42d961faa..17a170cb1 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -57,14 +57,15 @@ public class ItemProvider extends PacketExtensionProvider String payloadElemName = parser.getName(); String payloadNS = parser.getNamespace(); - if (ProviderManager.getExtensionProvider(payloadElemName, payloadNS) == null) + final PacketExtensionProvider extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS); + if (extensionProvider == null) { CharSequence payloadText = PacketParserUtils.parseElement(parser, true); return new PayloadItem(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText)); } else { - return new PayloadItem(id, node, PacketParserUtils.parsePacketExtension(payloadElemName, payloadNS, parser)); + return new PayloadItem(id, node, extensionProvider.parse(parser)); } } }