Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/net/www/protocol/jar/B5105410.java
41159 views
1
/*
2
* Copyright (c) 2004, 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
/**
25
* @test
26
* @bug 5105410
27
* @run main/othervm B5105410
28
* @summary ZipFile$ZipFileInputStream doesn't close handle to zipfile
29
*/
30
31
import java.io.File;
32
import java.io.IOException;
33
import java.io.InputStream;
34
import java.net.URL;
35
import java.net.URLConnection;
36
import java.nio.file.Files;
37
import java.nio.file.Paths;
38
39
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
40
41
public class B5105410 {
42
public static void main (String[] args) throws Exception {
43
setup();
44
URL url = new URL("jar:file:./foo2.jar!/bar.txt");
45
URLConnection urlc = url.openConnection();
46
urlc.setUseCaches(false);
47
InputStream is = urlc.getInputStream();
48
is.read();
49
is.close();
50
File file = new File("foo2.jar");
51
if (!file.delete()) {
52
throw new RuntimeException("Could not delete foo2.jar");
53
}
54
if (file.exists()) {
55
throw new RuntimeException("foo2.jar still exists");
56
}
57
}
58
59
static void setup() throws IOException {
60
Files.copy(Paths.get(System.getProperty("test.src"), "foo2.jar"),
61
Paths.get(".", "foo2.jar"), REPLACE_EXISTING);
62
}
63
}
64
65
66