mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 10:37:59 +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>();
|
serviceAddresses = new LinkedList<String>();
|
||||||
// Send the disco packet to the server itself
|
// 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
|
// Check if the server supports XEP-33
|
||||||
if (info.containsFeature(feature)) {
|
if (info.containsFeature(feature)) {
|
||||||
serviceAddresses.add(serviceName);
|
serviceAddresses.add(serviceName);
|
||||||
|
@ -728,8 +735,14 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
return serviceAddresses;
|
return serviceAddresses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DiscoverItems items;
|
||||||
|
try {
|
||||||
// Get the disco items and send the disco packet to each server item
|
// 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()) {
|
for (DiscoverItems.Item item : items.getItems()) {
|
||||||
try {
|
try {
|
||||||
// TODO is it OK here in all cases to query without the node attribute?
|
// TODO is it OK here in all cases to query without the node attribute?
|
||||||
|
|
Loading…
Reference in a new issue