From: jprocter Date: Wed, 5 Sep 2012 20:52:54 +0000 (+0100) Subject: patch for NPE when no services are available to resolve against X-Git-Tag: Jalview_2_9~331 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7a54eb647645a6be8d09f134f878ef2a03a0ebd9;p=jalview.git patch for NPE when no services are available to resolve against --- diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index c0addfe..c4ef059 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -821,21 +821,27 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ public Jws2Instance getPreferredServiceFor(String[] serviceURLs) { - HashSet urls=new HashSet(); + HashSet urls = new HashSet(); urls.addAll(Arrays.asList(serviceURLs)); - Jws2Instance match=null; - for (Jws2Instance svc:services) + Jws2Instance match = null; + if (services != null) { - if (urls.contains(svc.getServiceTypeURI())) + for (Jws2Instance svc : services) { - if (match==null) { - // for moment we always pick service from server ordered first in user's preferences - match=svc; - } - if (urls.contains(svc.getUri())) + if (urls.contains(svc.getServiceTypeURI())) { - // stop and return - we've matched type URI and URI for service endpoint - return svc; + if (match == null) + { + // for moment we always pick service from server ordered first in + // user's preferences + match = svc; + } + if (urls.contains(svc.getUri())) + { + // stop and return - we've matched type URI and URI for service + // endpoint + return svc; + } } } }