Fix file descriptor leak

This commit is contained in:
Christian Beikov 2022-11-22 18:14:25 +01:00
parent 818bb41091
commit c6fa10de6e
2 changed files with 9 additions and 2 deletions

View File

@ -60,7 +60,7 @@ public class ScriptSourceInputFromUrl extends AbstractScriptSourceInput {
@Override
protected void releaseReader(Reader reader) {
try {
prepareReader().close();
reader.close();
}
catch (IOException e) {
log.warn( "Unable to close file reader for generation script source" );

View File

@ -2,7 +2,9 @@ package org.hibernate.orm.test.tool.schema;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
@ -56,7 +58,12 @@ public class DefaultImportFileExecutionTest {
public void tearDown() {
serviceRegistry.close();
if ( defaultImportFile.exists() ) {
defaultImportFile.delete();
try {
Files.delete( defaultImportFile.toPath() );
}
catch (IOException e) {
throw new RuntimeException( e );
}
}
}