Merge branch '2.7.x'
See gh-32086
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -128,6 +128,9 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, RandomAccessData data, JarEntryFilter filter,
|
||||
JarFileType type, Supplier<Manifest> manifestSupplier) throws IOException {
|
||||
super(rootFile.getFile());
|
||||
if (System.getSecurityManager() == null) {
|
||||
super.close();
|
||||
}
|
||||
this.rootFile = rootFile;
|
||||
this.pathFromRoot = pathFromRoot;
|
||||
CentralDirectoryParser parser = new CentralDirectoryParser();
|
||||
@@ -139,7 +142,8 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
try {
|
||||
close();
|
||||
this.rootFile.close();
|
||||
super.close();
|
||||
}
|
||||
catch (IOException ioex) {
|
||||
}
|
||||
@@ -184,13 +188,8 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||
JarFileWrapper getWrapper() throws IOException {
|
||||
JarFileWrapper wrapper = this.wrapper;
|
||||
if (wrapper == null) {
|
||||
synchronized (this) {
|
||||
if (this.wrapper != null) {
|
||||
return this.wrapper;
|
||||
}
|
||||
wrapper = new JarFileWrapper(this);
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
wrapper = new JarFileWrapper(this);
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
@@ -356,13 +355,11 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
super.close();
|
||||
if (this.type == JarFileType.DIRECT) {
|
||||
this.rootFile.close();
|
||||
}
|
||||
this.closed = true;
|
||||
super.close();
|
||||
if (this.type == JarFileType.DIRECT) {
|
||||
this.rootFile.close();
|
||||
}
|
||||
this.closed = true;
|
||||
}
|
||||
|
||||
private void ensureOpen() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -40,6 +40,9 @@ class JarFileWrapper extends AbstractJarFile {
|
||||
JarFileWrapper(JarFile parent) throws IOException {
|
||||
super(parent.getRootJarFile().getFile());
|
||||
this.parent = parent;
|
||||
if (System.getSecurityManager() == null) {
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.boot.loader.jar;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -166,7 +165,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
if (inputStream == null) {
|
||||
throwFileNotFound(this.jarEntryName, this.jarFile);
|
||||
}
|
||||
return new ConnectionInputStream(inputStream);
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
private void throwFileNotFound(Object entry, AbstractJarFile jarFile) throws FileNotFoundException {
|
||||
@@ -291,19 +290,6 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return new JarURLConnection(null, jarFile, jarEntryName);
|
||||
}
|
||||
|
||||
private class ConnectionInputStream extends FilterInputStream {
|
||||
|
||||
ConnectionInputStream(InputStream in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
JarURLConnection.this.jarFile.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A JarEntryName parsed from a URL String.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2020 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.
|
||||
@@ -61,7 +61,6 @@ class JarFileWrapperTests {
|
||||
@AfterEach
|
||||
void cleanup() throws Exception {
|
||||
this.parent.close();
|
||||
this.wrapper.close();
|
||||
}
|
||||
|
||||
private File createTempJar(File temp) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user