commit
02494d63d2
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -126,7 +126,9 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||||
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter,
|
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter,
|
||||||
JarFileType type, Supplier<Manifest> manifestSupplier) throws IOException {
|
JarFileType type, Supplier<Manifest> manifestSupplier) throws IOException {
|
||||||
super(rootFile.getFile());
|
super(rootFile.getFile());
|
||||||
|
if (System.getSecurityManager() == null) {
|
||||||
super.close();
|
super.close();
|
||||||
|
}
|
||||||
this.rootFile = rootFile;
|
this.rootFile = rootFile;
|
||||||
this.pathFromRoot = pathFromRoot;
|
this.pathFromRoot = pathFromRoot;
|
||||||
CentralDirectoryParser parser = new CentralDirectoryParser();
|
CentralDirectoryParser parser = new CentralDirectoryParser();
|
||||||
|
|
@ -137,7 +139,12 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||||
this.data = parser.parse(data, filter == null);
|
this.data = parser.parse(data, filter == null);
|
||||||
}
|
}
|
||||||
catch (RuntimeException ex) {
|
catch (RuntimeException ex) {
|
||||||
close();
|
try {
|
||||||
|
this.rootFile.close();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
catch (IOException ioex) {
|
||||||
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
this.manifestSupplier = (manifestSupplier != null) ? manifestSupplier : () -> {
|
this.manifestSupplier = (manifestSupplier != null) ? manifestSupplier : () -> {
|
||||||
|
|
@ -337,10 +344,11 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||||
if (this.closed) {
|
if (this.closed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.closed = true;
|
super.close();
|
||||||
if (this.type == JarFileType.DIRECT) {
|
if (this.type == JarFileType.DIRECT) {
|
||||||
this.rootFile.close();
|
this.rootFile.close();
|
||||||
}
|
}
|
||||||
|
this.closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureOpen() {
|
private void ensureOpen() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -40,8 +40,10 @@ class JarFileWrapper extends AbstractJarFile {
|
||||||
JarFileWrapper(JarFile parent) throws IOException {
|
JarFileWrapper(JarFile parent) throws IOException {
|
||||||
super(parent.getRootJarFile().getFile());
|
super(parent.getRootJarFile().getFile());
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
if (System.getSecurityManager() == null) {
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
URL getUrl() throws MalformedURLException {
|
URL getUrl() throws MalformedURLException {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue