FanfictionApi: fix NPE
authorNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 17:01:07 +0000 (19:01 +0200)
committerNiki Roo <niki@nikiroo.be>
Tue, 23 Apr 2019 17:01:07 +0000 (19:01 +0200)
src/be/nikiroo/fanfix/supported/FimfictionApi.java

index 887f5f9c121397a4b8e90d7023c8d1ffac073f9b..a64e4c082f4eccbe5e1ae9fcc88745306207a5fc 100644 (file)
@@ -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();