@@ -252,19 +252,22 @@ private static Map<String, GenomeListItem> getCachedGenomeList() {
252
252
try {
253
253
BufferedReader reader = new BufferedReader (new FileReader (file ));
254
254
JsonParser parser = new JsonParser ();
255
- JsonObject json = parser .parse (reader ).getAsJsonObject ();
256
- JsonElement id = json .get ("id" );
257
- JsonElement name = json .get ("name" );
258
- JsonElement fastaURL = json .get ("fastaURL" );
259
- if (id != null && name != null && fastaURL != null ) {
260
- if (cachedGenomes .containsKey (id .getAsString ())) {
261
- File prevFile = new File (cachedGenomes .get (id .getAsString ()).getPath ());
262
- prevFile .delete ();
255
+ JsonElement rootElement = parser .parse (reader );
256
+ if (rootElement .isJsonObject ()) {
257
+ JsonObject json = rootElement .getAsJsonObject ();
258
+ JsonElement id = json .get ("id" );
259
+ JsonElement name = json .get ("name" );
260
+ JsonElement fastaURL = json .get ("fastaURL" );
261
+ if (id != null && name != null && fastaURL != null ) {
262
+ if (cachedGenomes .containsKey (id .getAsString ())) {
263
+ File prevFile = new File (cachedGenomes .get (id .getAsString ()).getPath ());
264
+ prevFile .delete ();
265
+ }
266
+ GenomeListItem item = new GenomeListItem (name .getAsString (), file .getAbsolutePath (), id .getAsString ());
267
+ cachedGenomes .put (item .getId (), item );
263
268
}
264
- GenomeListItem item = new GenomeListItem (name .getAsString (), file .getAbsolutePath (), id .getAsString ());
265
- cachedGenomes .put (item .getId (), item );
266
269
}
267
- } catch (FileNotFoundException e ) {
270
+ } catch (Exception e ) {
268
271
log .error ("Error parsing genome json: " + file .getAbsolutePath (), e );
269
272
}
270
273
}
0 commit comments