1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 04:22:05 +01:00

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.
This commit is contained in:
Florian Schmaus 2015-02-20 12:15:00 +01:00
parent 26d9a95c64
commit 19f96d2c40

View file

@ -57,14 +57,15 @@ public class ItemProvider extends PacketExtensionProvider<Item>
String payloadElemName = parser.getName(); String payloadElemName = parser.getName();
String payloadNS = parser.getNamespace(); String payloadNS = parser.getNamespace();
if (ProviderManager.getExtensionProvider(payloadElemName, payloadNS) == null) final PacketExtensionProvider<PacketExtension> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
if (extensionProvider == null)
{ {
CharSequence payloadText = PacketParserUtils.parseElement(parser, true); CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText)); return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
} }
else else
{ {
return new PayloadItem<PacketExtension>(id, node, PacketParserUtils.parsePacketExtension(payloadElemName, payloadNS, parser)); return new PayloadItem<PacketExtension>(id, node, extensionProvider.parse(parser));
} }
} }
} }