From b061fc2bb5b6e8397c7f3a40be521badad91e9af Mon Sep 17 00:00:00 2001 From: Tomasz Mikolajewski Date: Tue, 6 Dec 2016 10:05:05 +0900 Subject: [PATCH] Fix crashing StrictJarFile due to doubled closing. If the constuctor throws, then the handles would be closed without setting "closed" to true. As a result, the finalizer would close the handles again, which would cause a crash on the native side. Test: Unit tests are no longer flaky. Bug: 33301253 Change-Id: I527ba38d5d65ce844258d894441d4fe16bac6e23 --- core/java/android/util/jar/StrictJarFile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/util/jar/StrictJarFile.java b/core/java/android/util/jar/StrictJarFile.java index d9556aaaa9c0a..bc4a19d2d5e91 100644 --- a/core/java/android/util/jar/StrictJarFile.java +++ b/core/java/android/util/jar/StrictJarFile.java @@ -134,6 +134,7 @@ public final class StrictJarFile { } catch (IOException | SecurityException e) { nativeClose(this.nativeHandle); IoUtils.closeQuietly(fd); + closed = true; throw e; }