Bas van Schaik 2017-05-03 14:22:49 +01:00 committed by Vlad Mihalcea
parent 2d4600bbc7
commit 72e0d593b9
4 changed files with 97 additions and 87 deletions

View File

@ -145,8 +145,7 @@ public class ExplodedArchiveDescriptor extends AbstractArchiveDescriptor {
}
private void processZippedRoot(File rootFile, ArchiveContext context) {
try {
final JarFile jarFile = new JarFile(rootFile);
try (final JarFile jarFile = new JarFile(rootFile)){
final Enumeration<? extends ZipEntry> entries = jarFile.entries();
while ( entries.hasMoreElements() ) {
final ZipEntry zipEntry = entries.nextElement();

View File

@ -53,6 +53,7 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
return;
}
try {
final Enumeration<? extends ZipEntry> zipEntries = jarFile.entries();
while ( zipEntries.hasMoreElements() ) {
final ZipEntry zipEntry = zipEntries.nextElement();
@ -70,8 +71,8 @@ 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 (InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) )) {
final JarInputStream jarInputStream = new JarInputStream( is );
try ( final InputStream is = new BufferedInputStream( jarFile.getInputStream( zipEntry ) );
final JarInputStream jarInputStream = new JarInputStream( is )) {
ZipEntry subZipEntry = jarInputStream.getNextEntry();
while ( subZipEntry != null ) {
if ( ! subZipEntry.isDirectory() ) {
@ -147,6 +148,14 @@ public class JarFileBasedArchiveDescriptor extends AbstractArchiveDescriptor {
}
}
}
finally {
try {
jarFile.close();
}
catch ( Exception ignore ) {
}
}
}
private JarFile resolveJarFileReference() {
try {

View File

@ -50,7 +50,10 @@ public class ExceptionConverterImpl implements ExceptionConverter {
public RuntimeException convertCommitException(RuntimeException e) {
if ( sharedSessionContract.getFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
Throwable wrappedException;
if ( e instanceof PersistenceException ) {
if ( e instanceof HibernateException ) {
wrappedException = convert( (HibernateException) e );
}
else if ( e instanceof PersistenceException ) {
Throwable cause = e.getCause() == null ? e : e.getCause();
if ( cause instanceof HibernateException ) {
wrappedException = convert( (HibernateException) cause );
@ -59,9 +62,6 @@ public class ExceptionConverterImpl implements ExceptionConverter {
wrappedException = cause;
}
}
else if ( e instanceof HibernateException ) {
wrappedException = convert( (HibernateException) e );
}
else {
wrappedException = e;
}

View File

@ -215,7 +215,9 @@ public class SchemaUpdateTask extends MatchingTask {
properties.putAll( getProject().getProperties() );
}
else {
properties.load( new FileInputStream( propertiesFile ) );
try (FileInputStream fip = new FileInputStream( propertiesFile )){
properties.load( fip );
}
}
registryBuilder.applySettings( properties );