HHH-14760 Close resource - potential resource leak

Fixes https://hibernate.atlassian.net/browse/HHH-14760
This commit is contained in:
boris-unckel 2021-07-29 08:09:13 +02:00 committed by Sanne Grinovero
parent 42ff387193
commit c9b8776d3a
5 changed files with 14 additions and 8 deletions

View File

@ -414,7 +414,9 @@ public class SchemaExport {
Properties properties = new Properties();
if ( commandLineArgs.propertiesFile != null ) {
properties.load( new FileInputStream( commandLineArgs.propertiesFile ) );
try ( final FileInputStream fis = new FileInputStream( commandLineArgs.propertiesFile ) ) {
properties.load( fis );
}
}
ssrBuilder.applySettings( properties );

View File

@ -179,7 +179,9 @@ public class SchemaUpdate {
if ( parsedArgs.propertiesFile != null ) {
Properties props = new Properties();
props.load( new FileInputStream( parsedArgs.propertiesFile ) );
try ( final FileInputStream fis = new FileInputStream( parsedArgs.propertiesFile ) ) {
props.load( fis );
}
ssrBuilder.applySettings( props );
}

View File

@ -136,7 +136,9 @@ public class SchemaValidator {
if ( parsedArgs.propertiesFile != null ) {
Properties properties = new Properties();
properties.load( new FileInputStream( parsedArgs.propertiesFile ) );
try ( final FileInputStream fis = new FileInputStream( parsedArgs.propertiesFile ) ) {
properties.load( fis );
}
ssrBuilder.applySettings( properties );
}

View File

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

View File

@ -197,11 +197,9 @@ public class JpaDescriptorParser {
}
private void saveTimeStampCache(FileTimeStampChecker fileStampCheck) {
try {
File file = getSerializationTmpFile();
ObjectOutput out = new ObjectOutputStream( new FileOutputStream( file ) );
final File file = getSerializationTmpFile();
try ( final ObjectOutput out = new ObjectOutputStream( new FileOutputStream( file ) ) ) {
out.writeObject( fileStampCheck );
out.close();
context.logMessage(
Diagnostic.Kind.OTHER, "Serialized " + fileStampCheck + " into " + file.getAbsolutePath()
);