patch for NPE when no services are available to resolve against
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 5 Sep 2012 20:52:54 +0000 (21:52 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 5 Sep 2012 20:52:54 +0000 (21:52 +0100)
src/jalview/ws/jws2/Jws2Discoverer.java

index c0addfe..c4ef059 100644 (file)
@@ -821,21 +821,27 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
    */
   public Jws2Instance getPreferredServiceFor(String[] serviceURLs)
   {
-    HashSet<String> urls=new HashSet<String>();
+    HashSet<String> urls = new HashSet<String>();
     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;
+          }
         }
       }
     }