From: Niki Roo Date: Tue, 23 Apr 2019 17:01:07 +0000 (+0200) Subject: FanfictionApi: fix NPE X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a5b424414ec03d932911cc2ea2be0d64fe25b0ef;p=nikiroo-utils.git FanfictionApi: fix NPE --- diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index 887f5f9..a64e4c0 100644 --- a/src/be/nikiroo/fanfix/supported/FimfictionApi.java +++ b/src/be/nikiroo/fanfix/supported/FimfictionApi.java @@ -145,10 +145,11 @@ class FimfictionApi extends BasicSupport { String coverImageLink = getKeyJson(json, 0, "type", "story", "cover_image", "full"); if (!coverImageLink.trim().isEmpty()) { - InputStream in = null; + URL coverImageUrl = new URL(coverImageLink.trim()); + + InputStream in = Instance.getCache() + .open(coverImageUrl, this, true); try { - URL coverImageUrl = new URL(coverImageLink.trim()); - in = Instance.getCache().open(coverImageUrl, this, true); meta.setCover(new Image(in)); } finally { in.close();