From 7a54eb647645a6be8d09f134f878ef2a03a0ebd9 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 5 Sep 2012 21:52:54 +0100 Subject: [PATCH] patch for NPE when no services are available to resolve against --- src/jalview/ws/jws2/Jws2Discoverer.java | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) 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; + } } } } -- 1.7.10.2