From d767d72d69354489ecb1dc99489ea2709a10aabf Mon Sep 17 00:00:00 2001 From: Toromtomtom Date: Sat, 26 Sep 2020 13:20:32 +0200 Subject: [PATCH] Fix a fetcher test for the ShortDOIService (#6945) * throw an exception if no result was returned * fix formatting issue --- .../org/jabref/logic/importer/util/ShortDOIService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/importer/util/ShortDOIService.java b/src/main/java/org/jabref/logic/importer/util/ShortDOIService.java index 4c39290c0de..f18ed4e5ac0 100644 --- a/src/main/java/org/jabref/logic/importer/util/ShortDOIService.java +++ b/src/main/java/org/jabref/logic/importer/util/ShortDOIService.java @@ -53,7 +53,11 @@ private JSONObject makeRequest(DOI doi) throws ShortDOIServiceException { URLDownload urlDownload = new URLDownload(url); try { - return JsonReader.toJsonObject(urlDownload.asInputStream()); + JSONObject resultAsJSON = JsonReader.toJsonObject(urlDownload.asInputStream()); + if (resultAsJSON.isEmpty()) { + throw new ShortDOIServiceException("Cannot get short DOI"); + } + return resultAsJSON; } catch (ParseException | IOException | JSONException e) { throw new ShortDOIServiceException("Cannot get short DOI", e); }