Remove File.deleteOnExit in ZipEntryTest

File.deleteOnExit will not ensure file deletion

Bug: 37696493
Test: cts-tradefed run cts -m CtsLibcoreTestCases -t \
libcore.java.util.zip.ZipEntryTest

Change-Id: Ia3d4c93c0436719e09ef08ac25afbfd05222bc95
diff --git a/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java b/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
index f58c8aa..4e2df69 100644
--- a/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
+++ b/luni/src/test/java/libcore/java/util/zip/ZipEntryTest.java
@@ -24,6 +24,7 @@
 import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.jar.JarEntry;
@@ -39,12 +40,6 @@
   // tests is independent of the system clock.
   private static final long ENTRY_TIME = 1262304000000L; //  January 1, 2010 12:00:00 AM GMT
 
-  private static File createTemporaryZipFile() throws IOException {
-    File result = File.createTempFile("ZipFileTest", "zip");
-    result.deleteOnExit();
-    return result;
-  }
-
   private static ZipOutputStream createZipOutputStream(File f) throws IOException {
     return new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
   }
@@ -57,6 +52,23 @@
     return sb.toString();
   }
 
+  private List<File> temporaryFiles = new ArrayList<>();
+
+  private File createTemporaryZipFile() throws IOException {
+    File result = File.createTempFile("ZipFileTest", "zip");
+    temporaryFiles.add(result);
+    return result;
+  }
+
+  @Override
+  public void tearDown() throws Exception {
+    for (File file : temporaryFiles) {
+      file.delete();
+    }
+    temporaryFiles.clear();
+    super.tearDown();
+  }
+
   // http://code.google.com/p/android/issues/detail?id=4690
   public void test_utf8FileNames() throws Exception {
     // Create a zip file containing non-ASCII filenames.
@@ -174,7 +186,7 @@
     checkSetTime(4134153600000L); // January 3, 2101 12:00:00 AM GMT
   }
 
-  private static void checkSetTime(long time) throws IOException {
+  private void checkSetTime(long time) throws IOException {
     File f = createTemporaryZipFile();
     ZipOutputStream out = createZipOutputStream(f);
     ZipEntry ze = new ZipEntry("x");