1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

Make getMultipleRecipientServiceAddress more robust

to avoid

feature-not-implemented
	at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:182)
	at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:161)
	at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryManager.java:573)
	at org.jivesoftware.smackx.address.MultipleRecipientManager.getMultipleRecipienServiceAddress(MultipleRecipientManager.java:310)
 	at org.jivesoftware.smackx.address.MultipleRecipientManager.send$7a184d34(MultipleRecipientManager.java:82)

for e.g. Google Apps XMPP services.

This is not to be merged in master/4.1 branch as it already contains a
similar fix.
This commit is contained in:
Florian Schmaus 2014-08-10 17:16:08 +02:00
parent c3f6c51d0e
commit 0d890623c7

View file

@ -300,14 +300,21 @@ public class MultipleRecipientManager {
if (serviceAddress == null) { if (serviceAddress == null) {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
// Send the disco packet to the server itself // Send the disco packet to the server itself
DiscoverInfo info = sdm.discoverInfo(serviceName); DiscoverInfo info = null;
try {
info = sdm.discoverInfo(serviceName);
} catch (XMPPErrorException e) {
LOGGER.log(Level.WARNING, "Exception while discovering info of service", e);
}
// Check if the server supports XEP-33 // Check if the server supports XEP-33
if (info.containsFeature(MultipleAddresses.NAMESPACE)) { if (info != null && info.containsFeature(MultipleAddresses.NAMESPACE)) {
serviceAddress = serviceName; serviceAddress = serviceName;
} }
else { else {
// 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 = sdm.discoverItems(serviceName); DiscoverItems items;
try {
items = sdm.discoverItems(serviceName);
for (DiscoverItems.Item item : items.getItems()) { for (DiscoverItems.Item item : items.getItems()) {
try { try {
info = sdm.discoverInfo(item.getEntityID(), item.getNode()); info = sdm.discoverInfo(item.getEntityID(), item.getNode());
@ -324,6 +331,9 @@ public class MultipleRecipientManager {
break; break;
} }
} }
} catch (XMPPErrorException e) {
LOGGER.log(Level.WARNING, "Exception while disvering items of service", e);
}
} }
// Use the empty string to indicate that no service is known for this connection // Use the empty string to indicate that no service is known for this connection
serviceAddress = serviceAddress == null ? "" : serviceAddress; serviceAddress = serviceAddress == null ? "" : serviceAddress;