HHH-10938 - Fix memory leak when bootstrapping EntityManagerFactory

This commit is contained in:
Craig Andrews 2017-02-07 10:25:24 -05:00 committed by Vlad Mihalcea
parent 66cf8cb632
commit 5553b9df27
1 changed files with 28 additions and 34 deletions

View File

@ -70,9 +70,7 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
//
// This algorithm assumes that the zipped file is only the URL root (including entry), not
// just any random entry
try {
final InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) );
try {
try (InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) )) {
final JarInputStream jarInputStream = new JarInputStream( is );
ZipEntry subZipEntry = jarInputStream.getNextEntry();
while ( subZipEntry != null ) {
@ -106,10 +104,6 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
subZipEntry = jarInputStream.getNextEntry();
}
}
finally {
is.close();
}
}
catch (Exception e) {
throw new ArchiveException( "Error accessing JarFile entry [" + zipEntry.getName() + "]", e );
}
@ -118,8 +112,8 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
final String name = extractName( zipEntry );
final String relativeName = extractRelativeName( zipEntry );
final InputStreamAccess inputStreamAccess;
try {
inputStreamAccess = buildByteBasedInputStreamAccess( name, jarFile.getInputStream( zipEntry ) );
try (InputStream is = jarFile.getInputStream( zipEntry )) {
inputStreamAccess = buildByteBasedInputStreamAccess( name, is );
}
catch (IOException e) {
throw new ArchiveException(