From 1c52130ad032d77caac874c3a8be23a399a3ec93 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 7 Jun 2018 15:40:11 +0100 Subject: [PATCH] JAL-2755 correct Javadoc and error handling --- src/jalview/ext/ensembl/EnsemblLookup.java | 8 ++++++-- src/jalview/ext/ensembl/EnsemblMap.java | 5 ++++- src/jalview/ext/ensembl/EnsemblRestClient.java | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index 5f353f8..82690a3 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -131,7 +131,7 @@ public class EnsemblLookup extends EnsemblRestClient /** * Returns the gene id related to the given identifier (which may be for a - * gene, transcript or protein) + * gene, transcript or protein), or null if none is found * * @param identifier * @return @@ -143,7 +143,7 @@ public class EnsemblLookup extends EnsemblRestClient /** * Returns the gene id related to the given identifier (which may be for a - * gene, transcript or protein) + * gene, transcript or protein), or null if none is found * * @param identifier * @param objectType @@ -165,6 +165,10 @@ public class EnsemblLookup extends EnsemblRestClient */ protected String parseGeneId(JSONObject val) { + if (val == null) + { + return null; + } String geneId = null; String type = val.get(OBJECT_TYPE).toString(); if (OBJECT_TYPE_GENE.equalsIgnoreCase(type)) diff --git a/src/jalview/ext/ensembl/EnsemblMap.java b/src/jalview/ext/ensembl/EnsemblMap.java index 56657e0..8ca60de 100644 --- a/src/jalview/ext/ensembl/EnsemblMap.java +++ b/src/jalview/ext/ensembl/EnsemblMap.java @@ -257,7 +257,10 @@ public class EnsemblMap extends EnsemblRestClient { url = getIdMapUrl(domain, accession, start, end, cdsOrCdna); br = getHttpResponse(url, null); - return (parseIdMappingResponse(br, accession, domain)); + if (br != null) + { + return (parseIdMappingResponse(br, accession, domain)); + } } return null; } catch (Throwable t) diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index 92972eb..f36e111 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -259,7 +259,8 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher } /** - * Sends the HTTP request and gets the response as a reader + * Sends the HTTP request and gets the response as a reader. Returns null if + * the HTTP response code was not 200. * * @param url * @param ids @@ -268,7 +269,6 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher * in milliseconds * @return * @throws IOException - * if response code was not 200, or other I/O error */ protected BufferedReader getHttpResponse(URL url, List ids, int readTimeout) throws IOException -- 1.7.10.2