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

Fix NPE in ServiceDiscoveryManager

This commit is contained in:
Florian Schmaus 2020-03-09 14:41:52 +01:00
parent 00dd77b346
commit 863d0bf403
2 changed files with 9 additions and 1 deletions

View file

@ -162,6 +162,14 @@ public abstract class StanzaBuilder<B extends StanzaBuilder<B>> implements Stanz
return getThis(); return getThis();
} }
public final B addOptExtensions(Collection<? extends ExtensionElement> extensionElements) {
if (extensionElements == null) {
return getThis();
}
return addExtensions(extensionElements);
}
public final B addExtensions(Collection<? extends ExtensionElement> extensionElements) { public final B addExtensions(Collection<? extends ExtensionElement> extensionElements) {
for (ExtensionElement extensionElement : extensionElements) { for (ExtensionElement extensionElement : extensionElements) {
addExtension(extensionElement); addExtension(extensionElement);

View file

@ -178,7 +178,7 @@ public final class ServiceDiscoveryManager extends Manager {
// Add node identities // Add node identities
responseBuilder.addIdentities(nodeInformationProvider.getNodeIdentities()); responseBuilder.addIdentities(nodeInformationProvider.getNodeIdentities());
// Add packet extensions // Add packet extensions
responseBuilder.addExtensions(nodeInformationProvider.getNodePacketExtensions()); responseBuilder.addOptExtensions(nodeInformationProvider.getNodePacketExtensions());
} else { } else {
// Return <item-not-found/> error since specified node was not found // Return <item-not-found/> error since specified node was not found
responseBuilder.ofType(IQ.Type.error); responseBuilder.ofType(IQ.Type.error);