1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @bug 6907252
26 * @summary ZipFileInputStream Not Thread-Safe
27 * @library /lib/testlibrary
28 * @build jdk.testlibrary.*
29 * @run main ZipEntryFreeTest
30 */
31
32 import java.io.*;
33 import java.nio.file.Paths;
34 import java.util.Random;
35 import java.util.Timer;
36 import java.util.TimerTask;
37 import java.util.zip.*;
38 import jdk.testlibrary.FileUtils;
39
40 public class ZipEntryFreeTest extends Thread {
41
42 private static final int NUM_THREADS = 5;
43 private static final int TEST_ITERATIONS = 5;
44 private static final String ZIPFILE_NAME = "large.zip";
45 private static final String ZIPENTRY_NAME = "random.txt";
46 private static InputStream is = null;
47 final Timer timer = new Timer();
48
49 public static void main(String args[]) throws Exception {
50 createZipFile();
51 try {
52 for (int i = 0; i < TEST_ITERATIONS; i++) {
53 runTest();
54 }
55 } finally {
56 FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
57 }
58 }
|
1 /*
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* @test
25 * @bug 6907252
26 * @summary ZipFileInputStream Not Thread-Safe
27 * @library /test/lib
28 * @run main ZipEntryFreeTest
29 */
30
31 import java.io.*;
32 import java.nio.file.Paths;
33 import java.util.Random;
34 import java.util.Timer;
35 import java.util.TimerTask;
36 import java.util.zip.*;
37 import jdk.test.lib.util.FileUtils;
38
39 public class ZipEntryFreeTest extends Thread {
40
41 private static final int NUM_THREADS = 5;
42 private static final int TEST_ITERATIONS = 5;
43 private static final String ZIPFILE_NAME = "large.zip";
44 private static final String ZIPENTRY_NAME = "random.txt";
45 private static InputStream is = null;
46 final Timer timer = new Timer();
47
48 public static void main(String args[]) throws Exception {
49 createZipFile();
50 try {
51 for (int i = 0; i < TEST_ITERATIONS; i++) {
52 runTest();
53 }
54 } finally {
55 FileUtils.deleteFileIfExistsWithRetry(Paths.get(ZIPFILE_NAME));
56 }
57 }
|