Download: make sure to close in when caching
authorNiki Roo <niki@nikiroo.be>
Mon, 22 Apr 2019 10:34:04 +0000 (12:34 +0200)
committerNiki Roo <niki@nikiroo.be>
Mon, 22 Apr 2019 10:34:04 +0000 (12:34 +0200)
src/be/nikiroo/utils/Downloader.java

index 1ec4379a92b355cc1261e0d80d2c057dee0ff8ee..30ce4e798aff5300b30e14f200546b1e4d09ef16 100644 (file)
@@ -336,8 +336,11 @@ public class Downloader {
                if (in != null && cache != null) {
                        tracer.trace("Save to cache: " + originalUrl);
                        try {
-                               cache.save(in, originalUrl);
-                               in.close();
+                               try {
+                                       cache.save(in, originalUrl);
+                               } finally {
+                                       in.close();
+                               }
                                in = cache.load(originalUrl, true, false);
                        } catch (IOException e) {
                                tracer.error(new IOException(