mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Make ServiceDiscoveryManager.findServices() more robust
the method should not throw an exception if the discovery of the service fails.
This commit is contained in:
parent
0ed68cc18f
commit
a5eebf3840
1 changed files with 16 additions and 3 deletions
|
@ -716,7 +716,14 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
}
|
||||
serviceAddresses = new LinkedList<String>();
|
||||
// Send the disco packet to the server itself
|
||||
DiscoverInfo info = discoverInfo(serviceName);
|
||||
DiscoverInfo info;
|
||||
try {
|
||||
info = discoverInfo(serviceName);
|
||||
} catch (XMPPErrorException e) {
|
||||
// Be extra robust here: Return the empty linked list and log this situation
|
||||
LOGGER.log(Level.WARNING, "Could not discover information about service", e);
|
||||
return serviceAddresses;
|
||||
}
|
||||
// Check if the server supports XEP-33
|
||||
if (info.containsFeature(feature)) {
|
||||
serviceAddresses.add(serviceName);
|
||||
|
@ -728,8 +735,14 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
return serviceAddresses;
|
||||
}
|
||||
}
|
||||
DiscoverItems items;
|
||||
try {
|
||||
// Get the disco items and send the disco packet to each server item
|
||||
DiscoverItems items = discoverItems(serviceName);
|
||||
items = discoverItems(serviceName);
|
||||
} catch(XMPPErrorException e) {
|
||||
LOGGER.log(Level.WARNING, "Could not discover items about service", e);
|
||||
return serviceAddresses;
|
||||
}
|
||||
for (DiscoverItems.Item item : items.getItems()) {
|
||||
try {
|
||||
// TODO is it OK here in all cases to query without the node attribute?
|
||||
|
|
Loading…
Reference in a new issue