From: Niki Roo Date: Tue, 23 Apr 2019 17:01:07 +0000 (+0200) Subject: FanfictionApi: fix NPE X-Git-Tag: fanfix-swing-0.0.1~12^2~107^2 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a5b424414ec03d932911cc2ea2be0d64fe25b0ef;p=fanfix-swing.git FanfictionApi: fix NPE --- diff --git a/src/be/nikiroo/fanfix/supported/FimfictionApi.java b/src/be/nikiroo/fanfix/supported/FimfictionApi.java index 887f5f9c..a64e4c08 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();