HHH-10938 - Fix memory leak when bootstrapping EntityManagerFactory
This commit is contained in:
parent
66cf8cb632
commit
5553b9df27
|
@ -70,44 +70,38 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
|
||||||
//
|
//
|
||||||
// This algorithm assumes that the zipped file is only the URL root (including entry), not
|
// This algorithm assumes that the zipped file is only the URL root (including entry), not
|
||||||
// just any random entry
|
// just any random entry
|
||||||
try {
|
try (InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) )) {
|
||||||
final InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) );
|
final JarInputStream jarInputStream = new JarInputStream( is );
|
||||||
try {
|
ZipEntry subZipEntry = jarInputStream.getNextEntry();
|
||||||
final JarInputStream jarInputStream = new JarInputStream( is );
|
while ( subZipEntry != null ) {
|
||||||
ZipEntry subZipEntry = jarInputStream.getNextEntry();
|
if ( ! subZipEntry.isDirectory() ) {
|
||||||
while ( subZipEntry != null ) {
|
|
||||||
if ( ! subZipEntry.isDirectory() ) {
|
|
||||||
|
|
||||||
final String name = extractName( subZipEntry );
|
final String name = extractName( subZipEntry );
|
||||||
final String relativeName = extractRelativeName( subZipEntry );
|
final String relativeName = extractRelativeName( subZipEntry );
|
||||||
final InputStreamAccess inputStreamAccess = buildByteBasedInputStreamAccess( name, jarInputStream );
|
final InputStreamAccess inputStreamAccess = buildByteBasedInputStreamAccess( name, jarInputStream );
|
||||||
|
|
||||||
final ArchiveEntry entry = new ArchiveEntry() {
|
final ArchiveEntry entry = new ArchiveEntry() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNameWithinArchive() {
|
public String getNameWithinArchive() {
|
||||||
return relativeName;
|
return relativeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStreamAccess getStreamAccess() {
|
public InputStreamAccess getStreamAccess() {
|
||||||
return inputStreamAccess;
|
return inputStreamAccess;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final ArchiveEntryHandler entryHandler = context.obtainArchiveEntryHandler( entry );
|
final ArchiveEntryHandler entryHandler = context.obtainArchiveEntryHandler( entry );
|
||||||
entryHandler.handleEntry( entry, context );
|
entryHandler.handleEntry( entry, context );
|
||||||
}
|
|
||||||
|
|
||||||
subZipEntry = jarInputStream.getNextEntry();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
finally {
|
subZipEntry = jarInputStream.getNextEntry();
|
||||||
is.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -118,8 +112,8 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
|
||||||
final String name = extractName( zipEntry );
|
final String name = extractName( zipEntry );
|
||||||
final String relativeName = extractRelativeName( zipEntry );
|
final String relativeName = extractRelativeName( zipEntry );
|
||||||
final InputStreamAccess inputStreamAccess;
|
final InputStreamAccess inputStreamAccess;
|
||||||
try {
|
try (InputStream is = jarFile.getInputStream( zipEntry )) {
|
||||||
inputStreamAccess = buildByteBasedInputStreamAccess( name, jarFile.getInputStream( zipEntry ) );
|
inputStreamAccess = buildByteBasedInputStreamAccess( name, is );
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new ArchiveException(
|
throw new ArchiveException(
|
||||||
|
|
Loading…
Reference in New Issue