HHH-11718 - Fix various alerts reported by lgtm.com
Fpr more details:06f0c3acb2/files/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java (V218)
06f0c3acb2/files/hibernate-core/src/main/java/org/hibernate/boot/archive/internal/ExplodedArchiveDescriptor.java (V149)
06f0c3acb2/files/hibernate-core/src/main/java/org/hibernate/boot/archive/internal/JarFileBasedArchiveDescriptor.java (V74)
This commit is contained in:
parent
2d4600bbc7
commit
72e0d593b9
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue