From a5b424414ec03d932911cc2ea2be0d64fe25b0ef Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 23 Apr 2019 19:01:07 +0200 Subject: [PATCH] FanfictionApi: fix NPE --- src/be/nikiroo/fanfix/supported/FimfictionApi.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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(); -- 2.27.0