JAL-1064 patch for NPE when registerd database names do not resolve to one or more...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:16:58 +0000 (11:16 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 31 Aug 2012 10:17:05 +0000 (11:17 +0100)
src/jalview/ws/DBRefFetcher.java
src/jalview/ws/seqfetcher/ASequenceFetcher.java

index 1886172..5413a30 100644 (file)
@@ -153,7 +153,10 @@ public class DBRefFetcher implements Runnable
       }\r
       List<DbSourceProxy> srces=new ArrayList<DbSourceProxy>();\r
       for (String ddb:defdb) {\r
-        srces.addAll(sfetcher.getSourceProxy(ddb));\r
+        List<DbSourceProxy> srcesfordb=sfetcher.getSourceProxy(ddb);\r
+        if (srcesfordb!=null) {\r
+          srces.addAll(srcesfordb);\r
+        }\r
       }\r
       \r
       // append the selected sequence sources to the default dbs\r
index d4501d8..09a7a95 100644 (file)
@@ -262,10 +262,10 @@ public class ASequenceFetcher
   public List<DbSourceProxy> getSourceProxy(String db)\r
   {\r
     List<DbSourceProxy> dbs;\r
-    Collection<DbSourceProxy> dblist = FETCHABLEDBS.get(db).values();\r
-    if (dblist.size()>1)\r
-    {\r
-      DbSourceProxy[] l=dblist.toArray(new DbSourceProxy[0]);\r
+    Map<String,DbSourceProxy> dblist = FETCHABLEDBS.get(db);\r
+    if (dblist==null) {return new ArrayList<DbSourceProxy>();};\r
+    if (dblist.size()>1) {\r
+      DbSourceProxy[] l=dblist.values().toArray(new DbSourceProxy[0]);\r
       int i=0;\r
       String[] nm=new String[l.length];\r
       for (DbSourceProxy s:l)\r
@@ -279,7 +279,7 @@ public class ASequenceFetcher
         dbs.add(l[i]);\r
       }\r
     } else {\r
-      dbs = new ArrayList<DbSourceProxy>(dblist);\r
+      dbs = new ArrayList<DbSourceProxy>(dblist.values());\r
     }\r
     return dbs;\r
   }\r