mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 04:57:58 +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:
parent
26d9a95c64
commit
19f96d2c40
1 changed files with 3 additions and 2 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue