HHH-16963 Avoid H2's capability to register a JVM shutdown hook: causes classloader leaks during tests

This commit is contained in:
Sanne Grinovero 2023-07-18 00:12:33 +01:00
parent d812da6567
commit 042ea16b37
17 changed files with 17 additions and 17 deletions

View File

@ -18,7 +18,7 @@ ext {
'jdbc.driver': 'org.h2.Driver',
'jdbc.user' : 'sa',
'jdbc.pass' : '',
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000',
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE',
'connection.init_sql' : '',
'hibernate.dialect.native_param_markers' : 'true'
],

View File

@ -15,7 +15,7 @@
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.init_sql"></property>
<property name="hibernate.connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1</property>
<property name="hibernate.connection.url">jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.region_prefix">hibernate.test</property>
<property name="hibernate.jdbc.batch_size">0</property>

View File

@ -50,7 +50,7 @@ public class RefreshUpdatedDataTest extends BaseCoreFunctionalTestCase {
super.configure( cfg );
Properties properties = Environment.getProperties();
if ( H2Dialect.class.getName().equals( properties.get( Environment.DIALECT ) ) ) {
cfg.setProperty( Environment.URL, "jdbc:h2:mem:db-mvcc" );
cfg.setProperty( Environment.URL, "jdbc:h2:mem:db-mvcc;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
}
cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );

View File

@ -46,7 +46,7 @@ public class ConnectionCreatorTest extends BaseUnitTestCase {
Collections.emptyList(),
Collections.emptyMap()
),
"jdbc:h2:mem:test-bad-urls;nosuchparam=saywhat",
"jdbc:h2:mem:test-bad-urls;nosuchparam=saywhat;DB_CLOSE_ON_EXIT=FALSE",
new Properties(),
false,
null,

View File

@ -150,7 +150,7 @@ public class JpaSchemaGeneratorTest extends EntityManagerFactoryBasedFunctionalT
// We want a fresh db after emf close
// Unfortunately we have to use this dirty hack because the db seems not to be closed otherwise
settings.put( "hibernate.connection.url", "jdbc:h2:mem:db-schemagen" + schemagenNumber++
+ ";LOCK_TIMEOUT=10000" );
+ ";DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
EntityManagerFactoryBuilder emfb = Bootstrap.getEntityManagerFactoryBuilder(
buildPersistenceUnitDescriptor(),
settings

View File

@ -24,7 +24,7 @@ public class DatabaseConnectionInfo {
public static final DatabaseConnectionInfo INSTANCE = new DatabaseConnectionInfo();
public static final String DRIVER = "org.h2.Driver";
public static final String URL = "jdbc:h2:mem:hibernate-core";
public static final String URL = "jdbc:h2:mem:hibernate-core;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE";
public static final String USER = "hibernate";
public static final String PASS = "hibernate";

View File

@ -45,7 +45,7 @@ public class ConnectionsReleaseTest extends BaseUnitTestCase {
public static Properties getConnectionProviderProperties() {
Properties props = new Properties();
props.put( Environment.DRIVER, "org.h2.Driver" );
props.put( Environment.URL, String.format( "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", "db1" ) );
props.put( Environment.URL, String.format( "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE", "db1" ) );
props.put( Environment.USER, "sa" );
props.put( Environment.PASS, "" );
return props;

View File

@ -42,7 +42,7 @@ public class H2DialectDataBaseToUpperTest extends BaseUnitTestCase {
ssr = new StandardServiceRegistryBuilder()
.applySetting(
AvailableSettings.URL,
"jdbc:h2:mem:databaseToUpper;DATABASE_TO_UPPER=" + databaseToUpper
"jdbc:h2:mem:databaseToUpper;DATABASE_TO_UPPER=" + databaseToUpper + ";DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
)
.build();
final MetadataSources metadataSources = new MetadataSources( ssr );

View File

@ -13,7 +13,7 @@
<exclude-unlisted-classes />
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>

View File

@ -17,7 +17,7 @@
<property name="format_sql">false</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<property name="connection.url">jdbc:h2:mem:envers</property>
<property name="connection.url">jdbc:h2:mem:envers;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE</property>
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>

View File

@ -14,7 +14,7 @@
<properties>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"/>
<property name="hibernate.connection.url" value="jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"/>
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>

View File

@ -58,7 +58,7 @@ public class RefreshUpdatedDataTest {
.configure( "hibernate-config/hibernate.cfg.xml" );
if ( H2Dialect.class.equals( DialectContext.getDialect().getClass() ) ) {
ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc" );
ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
}
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );

View File

@ -123,7 +123,7 @@ public class TestHelper {
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
if ( H2Dialect.class.equals( DialectContext.getDialect().getClass() ) ) {
ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc" );
ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" );
}
return ssrb;
}

View File

@ -5,7 +5,7 @@
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
jdbc-0.proxool.alias=pool-one
jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1
jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
jdbc-0.proxool.driver-class=org.h2.Driver
jdbc-0.user=sa
jdbc-0.password=

View File

@ -5,7 +5,7 @@
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
jdbc-0.proxool.alias=pool-two
jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1
jdbc-0.proxool.driver-url=jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
jdbc-0.proxool.driver-class=org.h2.Driver
jdbc-0.user=sa
jdbc-0.password=

View File

@ -34,7 +34,7 @@ public class ConnectionProviderBuilder implements DialectCheck {
public static final String DRIVER = "org.h2.Driver";
public static final String DATA_SOURCE = "org.h2.jdbcx.JdbcDataSource";
// public static final String URL = "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1";
public static final String URL_FORMAT = "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1";
public static final String URL_FORMAT = "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE";
public static final String URL = URL_FORMAT;
public static final String USER = "sa";
public static final String PASS = "";

View File

@ -16,7 +16,7 @@ import org.hibernate.dialect.H2Dialect;
*/
public final class TestingDatabaseInfo {
public static volatile String DRIVER = "org.h2.Driver";
public static volatile String URL = "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1";
public static volatile String URL = "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE";
public static volatile String USER = "sa";
public static volatile String PASS = "";