diff --git a/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java b/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java index e9fe6c36d..247abd192 100644 --- a/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java +++ b/extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java @@ -557,7 +557,7 @@ public final class Socks5BytestreamManager implements BytestreamManager { List proxies = new ArrayList(); - // get all items form XMPP server + // get all items from XMPP server DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName()); Iterator itemIterator = discoverItems.getItems(); @@ -570,32 +570,38 @@ public final class Socks5BytestreamManager implements BytestreamManager { continue; } + DiscoverInfo proxyInfo; try { - DiscoverInfo proxyInfo; proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID()); - Iterator identities = proxyInfo.getIdentities(); - - // item must have category "proxy" and type "bytestream" - while (identities.hasNext()) { - Identity identity = identities.next(); - - if ("proxy".equalsIgnoreCase(identity.getCategory()) - && "bytestreams".equalsIgnoreCase(identity.getType())) { - proxies.add(item.getEntityID()); - break; - } - - /* - * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5 - * bytestream should be established - */ - this.proxyBlacklist.add(item.getEntityID()); - - } } - catch (XMPPException e) { + catch (NoResponseException e) { // blacklist errornous server + proxyBlacklist.add(item.getEntityID()); + continue; } + catch (XMPPErrorException e) { + // blacklist errornous server + proxyBlacklist.add(item.getEntityID()); + continue; + } + + Iterator identities = proxyInfo.getIdentities(); + + // item must have category "proxy" and type "bytestream" + while (identities.hasNext()) { + Identity identity = identities.next(); + + if ("proxy".equalsIgnoreCase(identity.getCategory()) + && "bytestreams".equalsIgnoreCase(identity.getType())) { + proxies.add(item.getEntityID()); + break; + } + + /* + * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5 + * bytestream should be established + */ this.proxyBlacklist.add(item.getEntityID()); + } }