1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +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 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);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
}
else
{
return new PayloadItem<PacketExtension>(id, node, PacketParserUtils.parsePacketExtension(payloadElemName, payloadNS, parser));
return new PayloadItem<PacketExtension>(id, node, extensionProvider.parse(parser));
}
}
}