Fix potential resource leaks
See gh-11624
This commit is contained in:
committed by
Stephane Nicoll
parent
0b22eb90b5
commit
5a4238acfc
@@ -215,16 +215,16 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
|
||||
@Override
|
||||
public void writeLoaderClasses(String loaderJarResourceName) throws IOException {
|
||||
URL loaderJar = getClass().getClassLoader().getResource(loaderJarResourceName);
|
||||
JarInputStream inputStream = new JarInputStream(
|
||||
new BufferedInputStream(loaderJar.openStream()));
|
||||
JarEntry entry;
|
||||
while ((entry = inputStream.getNextJarEntry()) != null) {
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
writeEntry(new JarArchiveEntry(entry),
|
||||
new InputStreamEntryWriter(inputStream, false));
|
||||
try (JarInputStream inputStream = new JarInputStream(
|
||||
new BufferedInputStream(loaderJar.openStream()))) {
|
||||
JarEntry entry;
|
||||
while ((entry = inputStream.getNextJarEntry()) != null) {
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
writeEntry(new JarArchiveEntry(entry),
|
||||
new InputStreamEntryWriter(inputStream, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user