HHH-12710 - BaseCoreFunctionalTestCase opens an InputStream for mapping files but never closes it
This commit is contained in:
parent
ebca36a768
commit
8bbd22967e
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.test.annotations.access.xml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -164,8 +165,12 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
|||
cfg.addAnnotatedClass( clazz );
|
||||
}
|
||||
for ( String configFile : configFiles ) {
|
||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
|
||||
cfg.addInputStream( is );
|
||||
try ( InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile ) ) {
|
||||
cfg.addInputStream( is );
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
}
|
||||
return ( SessionFactoryImplementor ) cfg.buildSessionFactory();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.testing.junit4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
@ -204,8 +205,12 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
|||
String[] xmlFiles = getXmlFiles();
|
||||
if ( xmlFiles != null ) {
|
||||
for ( String xmlFile : xmlFiles ) {
|
||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
|
||||
configuration.addInputStream( is );
|
||||
try ( InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile ) ) {
|
||||
configuration.addInputStream( is );
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalArgumentException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue