From db8e2870f2bf759bb7fd1c656e6677201ee78946 Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Tue, 1 Nov 2005 15:16:48 +0000 Subject: [PATCH] #getServiceNames will not fail if an items info cannot be discovered. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3012 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smackx/muc/MultiUserChat.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/org/jivesoftware/smackx/muc/MultiUserChat.java b/source/org/jivesoftware/smackx/muc/MultiUserChat.java index f78779bcf..37183a20b 100644 --- a/source/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/source/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -204,14 +204,20 @@ public class MultiUserChat { * @throws XMPPException if an error occured while trying to discover MUC services. */ public static Collection getServiceNames(XMPPConnection connection) throws XMPPException { - List answer = new ArrayList(); + final List answer = new ArrayList(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection); DiscoverItems items = discoManager.discoverItems(connection.getServiceName()); for (Iterator it = items.getItems(); it.hasNext();) { DiscoverItems.Item item = (DiscoverItems.Item) it.next(); - DiscoverInfo info = discoManager.discoverInfo(item.getEntityID()); - if (info.containsFeature("http://jabber.org/protocol/muc")) { - answer.add(item.getEntityID()); + try { + DiscoverInfo info = discoManager.discoverInfo(item.getEntityID()); + if (info.containsFeature("http://jabber.org/protocol/muc")) { + answer.add(item.getEntityID()); + } + } + catch (XMPPException e) { + // Trouble finding info in some cases. This is a workaround for + // discovering info on remote servers. } } return answer;