Skip to content

Commit

Permalink
Merge branch '2.4.x'
Browse files Browse the repository at this point in the history
Closes gh-26744
  • Loading branch information
philwebb committed Jun 3, 2021
2 parents 554cf9d + 1cda557 commit 02494d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -126,7 +126,9 @@ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccess
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter,
JarFileType type, Supplier<Manifest> manifestSupplier) throws IOException {
super(rootFile.getFile());
super.close();
if (System.getSecurityManager() == null) {
super.close();
}
this.rootFile = rootFile;
this.pathFromRoot = pathFromRoot;
CentralDirectoryParser parser = new CentralDirectoryParser();
Expand All @@ -137,7 +139,12 @@ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccess
this.data = parser.parse(data, filter == null);
}
catch (RuntimeException ex) {
close();
try {
this.rootFile.close();
super.close();
}
catch (IOException ioex) {
}
throw ex;
}
this.manifestSupplier = (manifestSupplier != null) ? manifestSupplier : () -> {
Expand Down Expand Up @@ -337,10 +344,11 @@ public void close() throws IOException {
if (this.closed) {
return;
}
this.closed = true;
super.close();
if (this.type == JarFileType.DIRECT) {
this.rootFile.close();
}
this.closed = true;
}

private void ensureOpen() {
Expand Down
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,9 @@ class JarFileWrapper extends AbstractJarFile {
JarFileWrapper(JarFile parent) throws IOException {
super(parent.getRootJarFile().getFile());
this.parent = parent;
super.close();
if (System.getSecurityManager() == null) {
super.close();
}
}

@Override
Expand Down

0 comments on commit 02494d6

Please sign in to comment.