Skip to content

Commit 042ea16

Browse files
committed
HHH-16963 Avoid H2's capability to register a JVM shutdown hook: causes classloader leaks during tests
1 parent d812da6 commit 042ea16

File tree

17 files changed

+17
-17
lines changed

17 files changed

+17
-17
lines changed

gradle/databases.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext {
1818
'jdbc.driver': 'org.h2.Driver',
1919
'jdbc.user' : 'sa',
2020
'jdbc.pass' : '',
21-
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000',
21+
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE',
2222
'connection.init_sql' : '',
2323
'hibernate.dialect.native_param_markers' : 'true'
2424
],

hibernate-core/src/test/bundles/templates/cfgxmlpar/org/hibernate/orm/test/jpa/pack/cfgxmlpar/hibernate.cfg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<property name="hibernate.connection.username">sa</property>
1616
<property name="hibernate.connection.password"></property>
1717
<property name="hibernate.connection.init_sql"></property>
18-
<property name="hibernate.connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1</property>
18+
<property name="hibernate.connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE</property>
1919
<property name="hibernate.cache.use_query_cache">true</property>
2020
<property name="hibernate.cache.region_prefix">hibernate.test</property>
2121
<property name="hibernate.jdbc.batch_size">0</property>

hibernate-core/src/test/java/org/hibernate/orm/test/cache/RefreshUpdatedDataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected void configure(Configuration cfg) {
5050
super.configure( cfg );
5151
Properties properties = Environment.getProperties();
5252
if ( H2Dialect.class.getName().equals( properties.get( Environment.DIALECT ) ) ) {
53-
cfg.setProperty( Environment.URL, "jdbc:h2:mem:db-mvcc" );
53+
cfg.setProperty( Environment.URL, "jdbc:h2:mem:db-mvcc;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
5454
}
5555
cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
5656
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );

hibernate-core/src/test/java/org/hibernate/orm/test/connection/ConnectionCreatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testBadUrl() throws Exception {
4646
Collections.emptyList(),
4747
Collections.emptyMap()
4848
),
49-
"jdbc:h2:mem:test-bad-urls;nosuchparam=saywhat",
49+
"jdbc:h2:mem:test-bad-urls;nosuchparam=saywhat;DB_CLOSE_ON_EXIT=FALSE",
5050
new Properties(),
5151
false,
5252
null,

hibernate-core/src/test/java/org/hibernate/orm/test/jpa/schemagen/JpaSchemaGeneratorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void doTest(Map<Object, Object> settings) {
150150
// We want a fresh db after emf close
151151
// Unfortunately we have to use this dirty hack because the db seems not to be closed otherwise
152152
settings.put( "hibernate.connection.url", "jdbc:h2:mem:db-schemagen" + schemagenNumber++
153-
+ ";LOCK_TIMEOUT=10000" );
153+
+ ";DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
154154
EntityManagerFactoryBuilder emfb = Bootstrap.getEntityManagerFactoryBuilder(
155155
buildPersistenceUnitDescriptor(),
156156
settings

hibernate-core/src/test/java/org/hibernate/orm/test/resource/common/DatabaseConnectionInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class DatabaseConnectionInfo {
2424
public static final DatabaseConnectionInfo INSTANCE = new DatabaseConnectionInfo();
2525

2626
public static final String DRIVER = "org.h2.Driver";
27-
public static final String URL = "jdbc:h2:mem:hibernate-core";
27+
public static final String URL = "jdbc:h2:mem:hibernate-core;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE";
2828
public static final String USER = "hibernate";
2929
public static final String PASS = "hibernate";
3030

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/ConnectionsReleaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ConnectionsReleaseTest extends BaseUnitTestCase {
4545
public static Properties getConnectionProviderProperties() {
4646
Properties props = new Properties();
4747
props.put( Environment.DRIVER, "org.h2.Driver" );
48-
props.put( Environment.URL, String.format( "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", "db1" ) );
48+
props.put( Environment.URL, String.format( "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE", "db1" ) );
4949
props.put( Environment.USER, "sa" );
5050
props.put( Environment.PASS, "" );
5151
return props;

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/H2DialectDataBaseToUpperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void setUp(String databaseToUpper) {
4242
ssr = new StandardServiceRegistryBuilder()
4343
.applySetting(
4444
AvailableSettings.URL,
45-
"jdbc:h2:mem:databaseToUpper;DATABASE_TO_UPPER=" + databaseToUpper
45+
"jdbc:h2:mem:databaseToUpper;DATABASE_TO_UPPER=" + databaseToUpper + ";DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
4646
)
4747
.build();
4848
final MetadataSources metadataSources = new MetadataSources( ssr );

hibernate-envers/src/demo/resources/META-INF/persistence.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<exclude-unlisted-classes />
1414
<properties>
1515
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
16-
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"/>
16+
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"/>
1717
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
1818
<property name="hibernate.connection.username" value="sa"/>
1919
<property name="hibernate.connection.password" value=""/>

hibernate-envers/src/test/resources/hibernate.test.session-cfg.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<property name="format_sql">false</property>
1818

1919
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
20-
<property name="connection.url">jdbc:h2:mem:envers</property>
20+
<property name="connection.url">jdbc:h2:mem:envers;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE</property>
2121
<property name="connection.driver_class">org.h2.Driver</property>
2222
<property name="connection.username">sa</property>
2323
<property name="connection.password"></property>

0 commit comments

Comments
 (0)