mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +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 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue