From 558dde5f7767a240af0272da51c52a1ca322ee14 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 17 Aug 2018 09:43:16 +0200 Subject: [PATCH] run Deflator.end() to get rid of StrictMode errors: java.lang.Throwable: Explicit termination method 'end' not called at dalvik.system.CloseGuard.open(CloseGuard.java:180) at java.util.zip.Deflater.(Deflater.java:171) at kellinwood.zipio.ZioEntryOutputStream.(ZioEntryOutputStream.java:35) at kellinwood.zipio.ZioEntry.getOutputStream(ZioEntry.java:482) at kellinwood.security.zipsigner.ZipSigner.signZip(ZipSigner.java:759) at kellinwood.security.zipsigner.ZipSigner.signZip(ZipSigner.java:664) at org.fdroid.fdroid.localrepo.LocalRepoKeyStore.signZip(LocalRepoKeyStore.java:213) at org.fdroid.fdroid.localrepo.LocalRepoManager.writeIndexJar(LocalRepoManager.java:492) at org.fdroid.fdroid.views.swap.SwapWorkflowActivity$PrepareSwapRepo.doInBackground(SwapWorkflowActivity.java:759) at org.fdroid.fdroid.views.swap.SwapWorkflowActivity$PrepareSwapRepo.doInBackground(SwapWorkflowActivity.java:709) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) E StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. --- .../java/kellinwood/zipio/ZioEntryOutputStream.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java b/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java index e13332412..2ce56c2f8 100644 --- a/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java +++ b/app/src/full/java/kellinwood/zipio/ZioEntryOutputStream.java @@ -28,18 +28,25 @@ public class ZioEntryOutputStream extends OutputStream { int crcValue = 0; OutputStream wrapped; OutputStream downstream; + Deflater deflater; public ZioEntryOutputStream(int compression, OutputStream wrapped) { this.wrapped = wrapped; - if (compression != 0) - downstream = new DeflaterOutputStream(wrapped, new Deflater(Deflater.BEST_COMPRESSION, true)); - else downstream = wrapped; + if (compression != 0) { + deflater = new Deflater(Deflater.BEST_COMPRESSION, true); + downstream = new DeflaterOutputStream(wrapped, deflater); + } else { + downstream = wrapped; + } } public void close() throws IOException { downstream.flush(); downstream.close(); crcValue = (int) crc.getValue(); + if (deflater != null) { + deflater.end(); + } } public int getCRC() {