From e51c210d782da2ad9d102c4a02f37ddfca0ae67a Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 25 Jan 2022 14:56:42 +0100 Subject: [PATCH] squash lots of warnings in services change the raw Map representation of config properties to Map --- .../AbstractMultiTenancyTest.java | 3 +- .../DatabaseTimeZoneMultiTenancyTest.java | 5 +- .../internal/AgroalConnectionProvider.java | 26 ++--- .../c3p0/internal/C3P0ConnectionProvider.java | 23 ++--- .../test/c3p0/C3P0ConnectionProviderTest.java | 7 +- .../c3p0/C3P0DefaultIsolationLevelTest.java | 2 +- .../c3p0/C3P0DifferentIsolationLevelTest.java | 3 +- .../c3p0/C3P0ProxyConnectionProvider.java | 4 +- .../dialect/CommunityDialectFactoryTest.java | 13 +-- .../internal/CfgXmlAccessServiceImpl.java | 2 +- .../CfgXmlAccessServiceInitiator.java | 2 +- .../boot/cfgxml/spi/LoadedConfig.java | 24 +++-- ...DefaultSessionFactoryBuilderInitiator.java | 2 +- .../SessionFactoryOptionsBuilder.java | 12 +-- .../boot/model/TypeBeanInstanceProducer.java | 1 - .../registry/StandardServiceInitiator.java | 2 +- .../StandardServiceRegistryBuilder.java | 84 ++++++++-------- .../internal/StandardServiceRegistryImpl.java | 41 +++----- .../internal/BytecodeProviderInitiator.java | 2 +- .../ProxyFactoryFactoryInitiator.java | 2 +- .../internal/NoCachingRegionFactory.java | 2 +- .../internal/RegionFactoryInitiator.java | 9 +- .../cache/spi/AbstractRegionFactory.java | 4 +- .../hibernate/cache/spi/RegionFactory.java | 2 +- .../java/org/hibernate/cfg/Configuration.java | 6 +- .../internal/ConfigurationServiceImpl.java | 9 +- .../ConfigurationServiceInitiator.java | 2 +- .../config/spi/ConfigurationService.java | 2 +- .../batch/internal/BatchBuilderInitiator.java | 4 +- .../UnmodifiableBatchBuilderInitiator.java | 3 +- .../internal/ConnectionCreatorFactory.java | 2 +- .../ConnectionCreatorFactoryImpl.java | 2 +- .../internal/ConnectionProviderInitiator.java | 97 ++++++++----------- .../DatasourceConnectionProviderImpl.java | 6 +- .../DriverManagerConnectionProviderImpl.java | 13 ++- ...ultiTenantConnectionProviderInitiator.java | 13 +-- .../UserSuppliedConnectionProviderImpl.java | 2 +- ...asedMultiTenantConnectionProviderImpl.java | 2 +- ...AbstractMultiTenantConnectionProvider.java | 2 +- .../internal/RefCursorSupportInitiator.java | 2 +- .../dialect/internal/DialectFactoryImpl.java | 2 +- .../internal/DialectFactoryInitiator.java | 2 +- .../internal/DialectResolverInitiator.java | 2 +- .../jdbc/dialect/spi/DialectFactory.java | 2 +- .../internal/JdbcEnvironmentInitiator.java | 4 +- .../jdbc/internal/JdbcServicesImpl.java | 3 +- .../jdbc/internal/JdbcServicesInitiator.java | 2 +- .../engine/jdbc/spi/SqlStatementLogger.java | 8 +- .../engine/jndi/internal/JndiServiceImpl.java | 20 ++-- .../jndi/internal/JndiServiceInitiator.java | 2 +- .../internal/AbstractJtaPlatform.java | 2 +- .../internal/JtaPlatformInitiator.java | 5 +- .../JtaPlatformResolverInitiator.java | 2 +- .../EntityCopyObserverFactoryInitiator.java | 10 +- .../hibernate/exception/spi/Configurable.java | 5 +- .../exception/spi/SQLExceptionConverter.java | 15 +-- .../spi/ViolatedConstraintNameExtractor.java | 3 +- .../internal/util/PropertiesHelper.java | 24 +++++ .../jpa/HibernatePersistenceProvider.java | 19 ++-- .../EntityManagerFactoryBuilderImpl.java | 37 +++---- .../PersisterClassResolverInitiator.java | 5 +- .../internal/PersisterFactoryInitiator.java | 8 +- ...opertyAccessStrategyResolverInitiator.java | 2 +- .../spi/AbstractCommonQueryContract.java | 10 +- .../spi/ContainedBeanImplementor.java | 2 +- .../container/spi/ExtendedBeanManager.java | 2 +- .../resource/beans/spi/ManagedBean.java | 2 +- .../beans/spi/ManagedBeanRegistry.java | 2 +- .../spi/ManagedBeanRegistryInitiator.java | 14 +-- .../spi/ProvidedInstanceManagedBeanImpl.java | 2 +- ...ransactionCoordinatorBuilderInitiator.java | 2 +- .../service/StandardServiceInitiators.java | 6 +- .../internal/AbstractServiceRegistryImpl.java | 62 +++++------- ...sionFactoryServiceRegistryBuilderImpl.java | 12 +-- ...actoryServiceRegistryFactoryInitiator.java | 2 +- .../SessionFactoryServiceRegistryImpl.java | 7 +- ...andardSessionFactoryServiceInitiators.java | 4 +- .../hibernate/service/spi/Configurable.java | 2 +- .../SessionFactoryServiceRegistryBuilder.java | 5 +- .../org/hibernate/service/spi/Wrapped.java | 2 +- .../tool/schema/internal/Helper.java | 4 +- .../HibernateSchemaManagementTool.java | 19 ++-- .../schema/internal/SchemaCreatorImpl.java | 22 ++--- .../schema/internal/SchemaDropperImpl.java | 12 +-- .../SchemaManagementToolInitiator.java | 2 +- .../script/SqlScriptExtractorInitiator.java | 2 +- .../tool/schema/spi/ExecutionOptions.java | 2 +- .../tool/schema/spi/SchemaManagementTool.java | 8 +- .../spi/SchemaManagementToolCoordinator.java | 8 +- .../orm/test/annotations/SafeMappingTest.java | 3 +- .../test/annotations/SecuredBindingTest.java | 2 +- .../BeanValidationDisabledTest.java | 2 +- .../annotations/beanvalidation/DDLTest.java | 2 +- .../DDLWithoutCallbackTest.java | 2 +- .../duplicatedgenerator/DuplicateTest.java | 2 +- ...yUpdateQueryHandlingModeExceptionTest.java | 2 +- .../AbstractCharsetNamingStrategyTest.java | 3 +- .../annotations/onetomany/OneToManyTest.java | 2 +- .../batch/BatchOptimisticLockingTest.java | 2 +- .../OptionalSecondaryTableBatchTest.java | 2 +- .../QualifiedTableNamingTest.java | 4 +- .../binding/mixed/XMLMappingDisabledTest.java | 2 +- .../cascade/CascadeOnUninitializedTest.java | 2 +- ...nhancedLazyLoadingOnDeletedEntityTest.java | 2 +- .../NonRootEntityWithCacheAnnotationTest.java | 2 +- ...RootEntityWithCacheableAnnotationTest.java | 2 +- .../persister/PersisterClassProviderTest.java | 2 +- .../connection/ConnectionCreatorTest.java | 4 +- .../orm/test/connection/PropertiesTest.java | 5 +- .../connections/AggressiveReleaseTest.java | 3 +- .../BasicConnectionProviderTest.java | 3 +- ...xplicitConnectionProviderInstanceTest.java | 2 +- .../JdbcBatchingAgressiveReleaseTest.java | 3 +- .../connections/SuppliedConnectionTest.java | 3 +- .../ThreadLocalCurrentSessionTest.java | 3 +- .../MariaDBExtractSequenceMetadataTest.java | 3 +- .../SequenceInformationMariaDBTest.java | 3 +- .../dialect/resolver/DialectFactoryTest.java | 12 +-- .../BaseExceptionHandlingTest.java | 2 +- ...paOrNativeBootstrapFunctionalTestCase.java | 5 +- .../orm/test/filter/DynamicFilterTest.java | 2 +- .../test/flush/TestFlushJoinTransaction.java | 2 +- .../PostgreSQLIdentitySequenceTest.java | 3 +- .../InterceptorNonNullTransactionTest.java | 4 +- .../jdbc/internal/SessionJdbcBatchTest.java | 2 +- ...dateCustomEntityDirtinessStrategyTest.java | 2 +- .../jpa/compliance/tck2_2/QueryApiTest.java | 2 +- .../CachingWithSecondaryTablesTests.java | 4 +- .../caching/InheritedCacheableTest.java | 2 +- .../caching/SubclassOnlyCachingTests.java | 2 +- .../ConfigurationObjectSettingTest.java | 7 +- .../DiscriminatorMultiTenancyTest.java | 2 +- .../AbstractSchemaBasedMultiTenancyTest.java | 2 +- .../orm/test/query/QueryTimeOutTest.java | 2 +- ...mplianceAlreadyStartedTransactionTest.java | 2 +- ...mplianceAlreadyStartedTransactionTest.java | 2 +- .../schemaupdate/ConnectionsReleaseTest.java | 7 +- .../orm/test/service/ServiceRegistryTest.java | 8 +- .../NativeQuerySyncSpaceCachingTest.java | 2 +- .../SubclassProxyInterfaceTest.java | 2 +- .../test/tm/InterceptorTransactionTest.java | 2 +- .../schema/DropSchemaDuringJtaTxnTest.java | 6 +- ...allySchemaValidatorImplConnectionTest.java | 9 +- .../IndividuallySchemaValidatorImplTest.java | 15 +-- .../tool/schema/JtaPlatformLoggingTest.java | 2 +- ...agerManyToOneFetchModeSelectWhereTest.java | 2 +- ...EagerToManyWhereDontUseClassWhereTest.java | 2 +- .../EagerToManyWhereUseClassWhereTest.java | 2 +- .../LazyToManyWhereDontUseClassWhereTest.java | 2 +- .../LazyToManyWhereUseClassWhereTest.java | 2 +- ...agerManyToOneFetchModeSelectWhereTest.java | 2 +- ...EagerToManyWhereDontUseClassWhereTest.java | 2 +- .../EagerToManyWhereUseClassWhereTest.java | 2 +- .../LazyToManyWhereDontUseClassWhereTest.java | 2 +- .../hbm/LazyToManyWhereUseClassWhereTest.java | 2 +- .../test/queryhint/QueryHintHANATest.java | 2 +- ...calDateCustomSessionLevelTimeZoneTest.java | 4 +- .../java/org/hibernate/test/tm/CMTTest.java | 2 +- .../boot/internal/EnversServiceImpl.java | 2 +- .../boot/internal/EnversServiceInitiator.java | 2 +- .../customtype/UnspecifiedEnumTypeTest.java | 2 +- ...tedDynamicComponentsAdvancedCasesTest.java | 2 +- .../lazy/ManyToOneLazyDeleteTest.java | 2 +- .../test/envers/AbstractOneSessionTest.java | 2 +- .../envers/BaseEnversFunctionalTestCase.java | 2 +- .../basic/OutsideTransactionTest.java | 2 +- .../dynamic/AuditedDynamicComponentTest.java | 2 - ...onsOfEntitiesQueryStoreAtDeletionTest.java | 2 +- .../EntityNamesTest.java | 2 +- .../internal/HikariCPConnectionProvider.java | 6 +- .../internal/HikariConfigurationUtil.java | 14 +-- .../jcache/internal/JCacheRegionFactory.java | 10 +- .../jcache/JCacheClasspathConfigUriTest.java | 2 +- .../jcache/JCacheConfigRelativePathTest.java | 2 +- .../orm/test/jcache/JCacheConfigUrlTest.java | 2 +- ...sactionalCacheConcurrencyStrategyTest.java | 2 +- .../stat/MicrometerCacheStatisticsTest.java | 2 +- .../internal/ProxoolConnectionProvider.java | 4 +- ...ProxoolTransactionIsolationConfigTest.java | 6 +- .../testing/ServiceRegistryBuilder.java | 12 ++- .../boot/DialectFactoryTestingImpl.java | 2 +- .../boot/ServiceRegistryTestingImpl.java | 19 ++-- .../testing/cache/CachingRegionFactory.java | 2 +- .../BaseTransactionIsolationConfigTest.java | 17 ++-- .../env/ConnectionProviderBuilder.java | 7 +- .../jdbc/ConnectionProviderDelegate.java | 5 +- .../testing/jdbc/DataSourceStub.java | 3 +- .../testing/jdbc/SQLStatementInterceptor.java | 5 +- ...edDriverManagerConnectionProviderImpl.java | 4 +- .../jta/JtaAwareConnectionProviderImpl.java | 34 +++---- .../testing/jta/TestingJtaBootstrap.java | 3 +- .../junit4/BaseCoreFunctionalTestCase.java | 1 + .../BaseNonConfigCoreFunctionalTestCase.java | 4 +- .../junit/EntityManagerFactoryExtension.java | 3 +- .../testing/orm/junit/ExtraAssertions.java | 6 +- .../orm/junit/ServiceRegistryExtension.java | 2 +- .../orm/junit/SessionFactoryExtension.java | 9 +- .../testing/transaction/TransactionUtil.java | 4 +- .../internal/ViburDBCPConnectionProvider.java | 23 +++-- .../ManagedProviderConnectionHelper.java | 3 +- .../hibernate/tool/hbm2ddl/SchemaUpdate.java | 8 +- 201 files changed, 640 insertions(+), 667 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/internal/util/PropertiesHelper.java diff --git a/documentation/src/test/java/org/hibernate/userguide/multitenancy/AbstractMultiTenancyTest.java b/documentation/src/test/java/org/hibernate/userguide/multitenancy/AbstractMultiTenancyTest.java index 914d97fd76..8691153e09 100644 --- a/documentation/src/test/java/org/hibernate/userguide/multitenancy/AbstractMultiTenancyTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/multitenancy/AbstractMultiTenancyTest.java @@ -27,6 +27,7 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.Stoppable; import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool; @@ -88,7 +89,7 @@ public abstract class AbstractMultiTenancyTest extends BaseUnitTestCase { DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure(properties); + connectionProvider.configure( PropertiesHelper.map(properties) ); connectionProviderMap.put(tenantIdentifier, connectionProvider); } //end::multitenacy-hibernate-MultiTenantConnectionProvider-example[] diff --git a/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseTimeZoneMultiTenancyTest.java b/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseTimeZoneMultiTenancyTest.java index 089d56c883..a9324580a8 100644 --- a/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseTimeZoneMultiTenancyTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseTimeZoneMultiTenancyTest.java @@ -34,6 +34,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.Stoppable; import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool; @@ -101,12 +102,12 @@ public class DatabaseTimeZoneMultiTenancyTest extends BaseUnitTestCase { Properties properties = properties(); properties.put( Environment.URL, - tenantUrl(properties.getProperty(Environment.URL), tenantIdentifier) + tenantUrl( properties.getProperty(Environment.URL), tenantIdentifier ) ); DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure(properties); + connectionProvider.configure( PropertiesHelper.map(properties) ); connectionProviderMap.put(tenantIdentifier, connectionProvider); diff --git a/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java b/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java index 7723955e1a..f1480e785a 100644 --- a/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java +++ b/hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java @@ -58,7 +58,7 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl // --- Configurable - private static void resolveIsolationSetting(Map properties, AgroalConnectionFactoryConfigurationSupplier cf) { + private static void resolveIsolationSetting(Map properties, AgroalConnectionFactoryConfigurationSupplier cf) { Integer isolation = ConnectionProviderInitiator.extractIsolation( properties ); if ( isolation != null ) { // Agroal resolves transaction isolation from the 'nice' name @@ -67,19 +67,19 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl } } - private static void copyProperty(Map properties, String key, Consumer consumer, Function converter) { - String value = properties.get( key ); - if ( value != null ) { - consumer.accept( converter.apply( value ) ); + private static void copyProperty(Map properties, String key, Consumer consumer, Function converter) { + Object value = properties.get( key ); + if ( value instanceof String ) { + consumer.accept( converter.apply( (String) value ) ); } } @Override - @SuppressWarnings( "unchecked" ) - public void configure(Map props) throws HibernateException { + public void configure(Map props) throws HibernateException { LOGGER.debug( "Configuring Agroal" ); try { - AgroalPropertiesReader agroalProperties = new AgroalPropertiesReader( CONFIG_PREFIX ).readProperties( props ); + AgroalPropertiesReader agroalProperties = new AgroalPropertiesReader( CONFIG_PREFIX ) + .readProperties( (Map) props ); //TODO: this is a garbage cast agroalProperties.modify().connectionPoolConfiguration( cp -> cp.connectionFactoryConfiguration( cf -> { copyProperty( props, AvailableSettings.DRIVER, cf::connectionProviderClassName, Function.identity() ); copyProperty( props, AvailableSettings.URL, cf::jdbcUrl, Function.identity() ); @@ -119,15 +119,17 @@ public class AgroalConnectionProvider implements ConnectionProvider, Configurabl } @Override - @SuppressWarnings( "rawtypes" ) - public boolean isUnwrappableAs(Class unwrapType) { - return ConnectionProvider.class.equals( unwrapType ) || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ); + public boolean isUnwrappableAs(Class unwrapType) { + return ConnectionProvider.class.equals( unwrapType ) + || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) + || DataSource.class.isAssignableFrom( unwrapType ); } @Override @SuppressWarnings( "unchecked" ) public T unwrap(Class unwrapType) { - if ( ConnectionProvider.class.equals( unwrapType ) || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) ) { + if ( ConnectionProvider.class.equals( unwrapType ) + || AgroalConnectionProvider.class.isAssignableFrom( unwrapType ) ) { return (T) this; } if ( DataSource.class.isAssignableFrom( unwrapType ) ) { diff --git a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java index c354d3c9e5..1b6c15b7b4 100644 --- a/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java +++ b/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java @@ -21,6 +21,7 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.UnknownUnwrapTypeException; import org.hibernate.service.spi.Configurable; @@ -67,11 +68,10 @@ public class C3P0ConnectionProvider private ServiceRegistryImplementor serviceRegistry; @Override - @SuppressWarnings("UnnecessaryUnboxing") public Connection getConnection() throws SQLException { final Connection c = ds.getConnection(); - if ( isolation != null && !isolation.equals( c.getTransactionIsolation() ) ) { - c.setTransactionIsolation( isolation.intValue() ); + if ( isolation != null && isolation != c.getTransactionIsolation() ) { + c.setTransactionIsolation( isolation ); } if ( c.getAutoCommit() != autocommit ) { c.setAutoCommit( autocommit ); @@ -85,7 +85,7 @@ public class C3P0ConnectionProvider } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || C3P0ConnectionProvider.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ); @@ -107,8 +107,7 @@ public class C3P0ConnectionProvider } @Override - @SuppressWarnings({"unchecked"}) - public void configure(Map props) { + public void configure(Map props) { final String jdbcDriverClass = (String) props.get( Environment.DRIVER ); final String jdbcUrl = (String) props.get( Environment.URL ); final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( props ); @@ -145,11 +144,7 @@ public class C3P0ConnectionProvider // turn hibernate.c3p0.* into c3p0.*, so c3p0 // gets a chance to see all hibernate.c3p0.* - for ( Object o : props.keySet() ) { - if ( !String.class.isInstance( o ) ) { - continue; - } - final String key = (String) o; + for ( String key : props.keySet() ) { if ( key.startsWith( "hibernate.c3p0." ) ) { final String newKey = key.substring( 15 ); if ( props.containsKey( newKey ) ) { @@ -185,9 +180,9 @@ public class C3P0ConnectionProvider final DataSource unpooled = DataSources.unpooledDataSource( jdbcUrl, connectionProps ); - final Map allProps = new HashMap(); + final Map allProps = new HashMap<>(); allProps.putAll( props ); - allProps.putAll( c3props ); + allProps.putAll( PropertiesHelper.map(c3props) ); ds = DataSources.pooledDataSource( unpooled, allProps ); } @@ -208,7 +203,7 @@ public class C3P0ConnectionProvider private void setOverwriteProperty( String hibernateStyleKey, String c3p0StyleKey, - Map hibp, + Map hibp, Properties c3p, Integer value) { if ( value != null ) { diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java index 8b797a08ed..1d41acc154 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ConnectionProviderTest.java @@ -7,7 +7,8 @@ package org.hibernate.test.c3p0; import java.lang.management.ManagementFactory; -import java.util.Properties; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -94,8 +95,8 @@ public class C3P0ConnectionProviderTest extends BaseCoreFunctionalTestCase { public void testIsolationPropertyCouldBeEmpty() { C3P0ConnectionProvider provider = new C3P0ConnectionProvider(); try { - Properties configuration = new Properties(); - configuration.setProperty( Environment.ISOLATION, "" ); + Map configuration = new HashMap<>(); + configuration.put( Environment.ISOLATION, "" ); provider.configure( configuration ); } finally { diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DefaultIsolationLevelTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DefaultIsolationLevelTest.java index 52555f316b..32fc4eddaf 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DefaultIsolationLevelTest.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DefaultIsolationLevelTest.java @@ -46,7 +46,7 @@ public class C3P0DefaultIsolationLevelTest extends } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { connectionProvider = new C3P0ProxyConnectionProvider(); settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider ); settings.put( AvailableSettings.ISOLATION, "READ_COMMITTED" ); diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DifferentIsolationLevelTest.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DifferentIsolationLevelTest.java index 55d4bd9ed3..56b1ea0a3e 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DifferentIsolationLevelTest.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0DifferentIsolationLevelTest.java @@ -19,7 +19,6 @@ import org.junit.Test; import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -47,7 +46,7 @@ public class C3P0DifferentIsolationLevelTest extends } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { connectionProvider = new C3P0ProxyConnectionProvider(); settings.put( AvailableSettings.CONNECTION_PROVIDER, connectionProvider ); settings.put( AvailableSettings.ISOLATION, "REPEATABLE_READ" ); diff --git a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java index 7e19668a89..41d5f2f5eb 100644 --- a/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java +++ b/hibernate-c3p0/src/test/java/org/hibernate/test/c3p0/C3P0ProxyConnectionProvider.java @@ -28,7 +28,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider { } @Override - public void configure(Map props) { + public void configure(Map props) { super.configure( props ); DataSource ds = unwrap( DataSource.class ); DataSource dataSource = spy( ds ); @@ -45,7 +45,7 @@ public class C3P0ProxyConnectionProvider extends C3P0ConnectionProvider { throw new IllegalStateException( e ); } - ReflectionUtil.setField( C3P0ConnectionProvider.class.cast( this ), "ds", dataSource ); + ReflectionUtil.setField( this, "ds", dataSource ); } @Override diff --git a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectFactoryTest.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectFactoryTest.java index 9f947f8394..1772f28c5a 100644 --- a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectFactoryTest.java +++ b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectFactoryTest.java @@ -6,7 +6,7 @@ */ package org.hibernate.community.dialect; -import java.util.Properties; +import java.util.HashMap; import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; @@ -14,8 +14,6 @@ import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl; -import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; -import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.orm.test.dialect.resolver.TestingDialectResolutionInfo; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -80,13 +78,8 @@ public class CommunityDialectFactoryTest extends BaseUnitTestCase { DialectResolver resolver) { dialectFactory.setDialectResolver( resolver ); Dialect resolved = dialectFactory.buildDialect( - new Properties(), - new DialectResolutionInfoSource() { - @Override - public DialectResolutionInfo getDialectResolutionInfo() { - return TestingDialectResolutionInfo.forDatabaseInfo( databaseName, driverName, majorVersion, minorVersion ); - } - } + new HashMap<>(), + () -> TestingDialectResolutionInfo.forDatabaseInfo( databaseName, driverName, majorVersion, minorVersion ) ); assertEquals( expected, resolved.getClass() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceImpl.java index 16700bd239..6baea079aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceImpl.java @@ -17,7 +17,7 @@ import org.hibernate.boot.cfgxml.spi.LoadedConfig; public class CfgXmlAccessServiceImpl implements CfgXmlAccessService { private final LoadedConfig aggregatedCfgXml; - public CfgXmlAccessServiceImpl(Map configurationValues) { + public CfgXmlAccessServiceImpl(Map configurationValues) { aggregatedCfgXml = (LoadedConfig) configurationValues.get( LOADED_CONFIG_KEY ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceInitiator.java index eb5e8d188a..96fb975cdb 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/CfgXmlAccessServiceInitiator.java @@ -22,7 +22,7 @@ public class CfgXmlAccessServiceInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new CfgXmlAccessServiceImpl( configurationValues ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java index 67422e729b..1e473ac792 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java @@ -38,11 +38,11 @@ public class LoadedConfig { private String sessionFactoryName; - private final Map configurationValues = new ConcurrentHashMap( 16, 0.75f, 1 ); + private final Map configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 ); private List cacheRegionDefinitions; private List mappingReferences; - private Map> eventListenerMap; + private Map,Set> eventListenerMap; public LoadedConfig(String sessionFactoryName) { this.sessionFactoryName = sessionFactoryName; @@ -52,7 +52,7 @@ public class LoadedConfig { return sessionFactoryName; } - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -64,7 +64,7 @@ public class LoadedConfig { return mappingReferences == null ? Collections.emptyList() : mappingReferences; } - public Map> getEventListenerMap() { + public Map, Set> getEventListenerMap() { return eventListenerMap == null ? Collections.emptyMap() : eventListenerMap; } @@ -93,7 +93,7 @@ public class LoadedConfig { if ( !jaxbCfg.getSessionFactory().getListener().isEmpty() ) { for ( JaxbCfgEventListenerType listener : jaxbCfg.getSessionFactory().getListener() ) { - final EventType eventType = EventType.resolveEventTypeByName( listener.getType().value() ); + final EventType eventType = EventType.resolveEventTypeByName( listener.getType().value() ); cfg.addEventListener( eventType, listener.getClazz() ); } } @@ -105,7 +105,7 @@ public class LoadedConfig { } final String eventTypeName = listenerGroup.getType().value(); - final EventType eventType = EventType.resolveEventTypeByName( eventTypeName ); + final EventType eventType = EventType.resolveEventTypeByName( eventTypeName ); for ( JaxbCfgEventListenerType listener : listenerGroup.getListener() ) { if ( listener.getType() != null ) { @@ -127,7 +127,6 @@ public class LoadedConfig { return value.trim(); } - @SuppressWarnings("unchecked") private void addConfigurationValue(String propertyName, String value) { value = trim( value ); configurationValues.put( propertyName, value ); @@ -146,7 +145,7 @@ public class LoadedConfig { } private static CacheRegionDefinition parseCacheRegionDefinition(Object cacheDeclaration) { - if ( JaxbCfgEntityCacheType.class.isInstance( cacheDeclaration ) ) { + if ( cacheDeclaration instanceof JaxbCfgEntityCacheType ) { final JaxbCfgEntityCacheType jaxbClassCache = (JaxbCfgEntityCacheType) cacheDeclaration; return new CacheRegionDefinition( CacheRegionDefinition.CacheRegionType.ENTITY, @@ -175,7 +174,7 @@ public class LoadedConfig { cacheRegionDefinitions.add( cacheRegionDefinition ); } - public void addEventListener(EventType eventType, String listenerClass) { + public void addEventListener(EventType eventType, String listenerClass) { if ( eventListenerMap == null ) { eventListenerMap = new HashMap<>(); } @@ -216,8 +215,7 @@ public class LoadedConfig { addEventListeners( incoming.getEventListenerMap() ); } - @SuppressWarnings("unchecked") - protected void addConfigurationValues(Map configurationValues) { + protected void addConfigurationValues(Map configurationValues) { if ( configurationValues == null ) { return; } @@ -247,7 +245,7 @@ public class LoadedConfig { this.cacheRegionDefinitions.addAll( cacheRegionDefinitions ); } - private void addEventListeners(Map> eventListenerMap) { + private void addEventListeners(Map, Set> eventListenerMap) { if ( eventListenerMap == null ) { return; } @@ -256,7 +254,7 @@ public class LoadedConfig { this.eventListenerMap = new HashMap<>(); } - for ( Map.Entry> incomingEntry : eventListenerMap.entrySet() ) { + for ( Map.Entry, Set> incomingEntry : eventListenerMap.entrySet() ) { Set listenerClasses = this.eventListenerMap.get( incomingEntry.getKey() ); if ( listenerClasses == null ) { listenerClasses = new HashSet<>(); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/DefaultSessionFactoryBuilderInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/DefaultSessionFactoryBuilderInitiator.java index 1ef0ed7bbb..ff29f3f289 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/DefaultSessionFactoryBuilderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/DefaultSessionFactoryBuilderInitiator.java @@ -20,7 +20,7 @@ public final class DefaultSessionFactoryBuilderInitiator implements StandardServ } @Override - public SessionFactoryBuilderService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public SessionFactoryBuilderService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return DefaultSessionFactoryBuilderService.INSTANCE; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java index 78b6d5ca01..8eeab82749 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java @@ -17,7 +17,6 @@ import java.util.TimeZone; import java.util.concurrent.Callable; import java.util.function.Supplier; -import org.hibernate.ConnectionReleaseMode; import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.EmptyInterceptor; import org.hibernate.EntityNameResolver; @@ -50,6 +49,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.id.uuid.LocalObjectUuidHelper; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.NullnessHelper; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jpa.spi.JpaCompliance; @@ -268,8 +268,8 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); - final Map configurationSettings = new HashMap<>(); - configurationSettings.putAll( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ); + final Map configurationSettings = new HashMap<>(); + configurationSettings.putAll( PropertiesHelper.map( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ) ); configurationSettings.putAll( cfgService.getSettings() ); if ( cfgService == null ) { cfgService = new ConfigurationServiceImpl( configurationSettings ); @@ -702,7 +702,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { } private static Interceptor determineInterceptor( - Map configurationSettings, + Map configurationSettings, StrategySelector strategySelector) { Object setting = configurationSettings.get( INTERCEPTOR ); if ( setting == null ) { @@ -724,7 +724,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { @SuppressWarnings("unchecked") private static Supplier determineStatelessInterceptor( - Map configurationSettings, + Map configurationSettings, StrategySelector strategySelector) { Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR ); @@ -761,7 +761,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { } private PhysicalConnectionHandlingMode interpretConnectionHandlingMode( - Map configurationSettings, + Map configurationSettings, StandardServiceRegistry serviceRegistry) { final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode.interpret( configurationSettings.get( CONNECTION_HANDLING ) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java index cd7bebeb71..9107cf44be 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java @@ -54,7 +54,6 @@ public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBoots } @Override - @SuppressWarnings("unchecked") public Map getConfigurationSettings() { return typeConfiguration.getServiceRegistry().getService( ConfigurationService.class ).getSettings(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java index 8154e86f1c..d961796814 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceInitiator.java @@ -28,5 +28,5 @@ public interface StandardServiceInitiator extends ServiceInit * * @return The initiated service. */ - R initiateService(Map configurationValues, ServiceRegistryImplementor registry); + R initiateService(Map configurationValues, ServiceRegistryImplementor registry); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java index 0df5ed6246..c497a98432 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/StandardServiceRegistryBuilder.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; import org.hibernate.boot.cfgxml.internal.ConfigLoader; import org.hibernate.boot.cfgxml.spi.LoadedConfig; @@ -20,6 +21,7 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Environment; import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; @@ -47,13 +49,13 @@ public class StandardServiceRegistryBuilder { public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry) { final LoadedConfig loadedConfig = new LoadedConfig( null ) { @Override - protected void addConfigurationValues(Map configurationValues) { + protected void addConfigurationValues(Map configurationValues) { // here, do nothing } }; return new StandardServiceRegistryBuilder( bootstrapServiceRegistry, - new HashMap(), + new HashMap<>(), loadedConfig ) { @Override @@ -66,13 +68,13 @@ public class StandardServiceRegistryBuilder { } /** - * The default resource name for a hibernate configuration xml file. + * The default resource name for a Hibernate configuration xml file. */ public static final String DEFAULT_CFG_RESOURCE_NAME = "hibernate.cfg.xml"; - private final Map settings; - private final List initiators; - private final List providedServices = new ArrayList<>(); + private final Map settings; + private final List> initiators; + private final List> providedServices = new ArrayList<>(); private boolean autoCloseRegistry = true; @@ -97,14 +99,14 @@ public class StandardServiceRegistryBuilder { } /** - * Intended for use exclusively from JPA boot-strapping, or extensions of + * Intended for use exclusively from JPA bootstrapping, or extensions of * this class. Consider this an SPI. * * @see #forJpa */ protected StandardServiceRegistryBuilder( BootstrapServiceRegistry bootstrapServiceRegistry, - Map settings, + Map settings, LoadedConfig loadedConfig) { this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); @@ -114,7 +116,7 @@ public class StandardServiceRegistryBuilder { } /** - * Intended for use exclusively from Quarkus boot-strapping, or extensions of + * Intended for use exclusively from Quarkus bootstrapping, or extensions of * this class which need to override the standard ServiceInitiator list. * Consider this an SPI. * @deprecated Quarkus will switch to use {@link #StandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)} @@ -122,9 +124,9 @@ public class StandardServiceRegistryBuilder { @Deprecated protected StandardServiceRegistryBuilder( BootstrapServiceRegistry bootstrapServiceRegistry, - Map settings, + Map settings, LoadedConfig loadedConfig, - List initiators) { + List> initiators) { this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.settings = settings; @@ -133,16 +135,16 @@ public class StandardServiceRegistryBuilder { } /** - * Intended for use exclusively from Quarkus boot-strapping, or extensions of + * Intended for use exclusively from Quarkus bootstrapping, or extensions of * this class which need to override the standard ServiceInitiator list. * Consider this an SPI. */ protected StandardServiceRegistryBuilder( BootstrapServiceRegistry bootstrapServiceRegistry, - Map settings, + Map settings, ConfigLoader loader, LoadedConfig loadedConfig, - List initiators) { + List> initiators) { this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.configLoader = loader; this.settings = settings; @@ -158,7 +160,7 @@ public class StandardServiceRegistryBuilder { public StandardServiceRegistryBuilder( BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline) { - this.settings = Environment.getProperties(); + this.settings = PropertiesHelper.map( Environment.getProperties() ); this.bootstrapServiceRegistry = bootstrapServiceRegistry; this.configLoader = new ConfigLoader( bootstrapServiceRegistry ); this.aggregatedCfgXml = loadedConfigBaseline; @@ -181,13 +183,12 @@ public class StandardServiceRegistryBuilder { * * @return List of standard initiators */ - private static List standardInitiatorList() { - final List initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() ); + private static List> standardInitiatorList() { + final List> initiators = new ArrayList<>( StandardServiceInitiators.LIST.size() ); initiators.addAll( StandardServiceInitiators.LIST ); return initiators; } - @SuppressWarnings("unused") public BootstrapServiceRegistry getBootstrapServiceRegistry() { return bootstrapServiceRegistry; } @@ -205,9 +206,8 @@ public class StandardServiceRegistryBuilder { * @see #configure() * @see #configure(String) */ - @SuppressWarnings({"unchecked"}) public StandardServiceRegistryBuilder loadProperties(String resourceName) { - settings.putAll( configLoader.loadProperties( resourceName ) ); + settings.putAll( PropertiesHelper.map( configLoader.loadProperties( resourceName ) ) ); return this; } @@ -224,9 +224,8 @@ public class StandardServiceRegistryBuilder { * @see #configure() * @see #configure(String) */ - @SuppressWarnings({"unchecked"}) public StandardServiceRegistryBuilder loadProperties(File file) { - settings.putAll( configLoader.loadProperties( file ) ); + settings.putAll( PropertiesHelper.map( configLoader.loadProperties( file ) ) ); return this; } @@ -262,7 +261,6 @@ public class StandardServiceRegistryBuilder { return configure( configLoader.loadConfigXmlUrl( url ) ); } - @SuppressWarnings({"unchecked"}) public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) { aggregatedCfgXml.merge( loadedConfig ); settings.putAll( loadedConfig.getConfigurationValues() ); @@ -278,25 +276,38 @@ public class StandardServiceRegistryBuilder { * * @return this, for method chaining */ - @SuppressWarnings({"unchecked", "UnusedDeclaration"}) public StandardServiceRegistryBuilder applySetting(String settingName, Object value) { settings.put( settingName, value ); return this; } /** - * Apply a groups of setting values. + * Apply a group of settings. * * @param settings The incoming settings to apply * * @return this, for method chaining */ - @SuppressWarnings({"unchecked", "UnusedDeclaration"}) - public StandardServiceRegistryBuilder applySettings(Map settings) { + public StandardServiceRegistryBuilder applySettings(Map settings) { this.settings.putAll( settings ); return this; } + /** + * Apply a group of settings. + * + * @param settings The incoming settings to apply + * + * @return this, for method chaining + */ + public StandardServiceRegistryBuilder applySettings(Properties settings) { + this.settings.putAll( PropertiesHelper.map(settings) ); + return this; + } + + /** + * Discard all the settings applied so far. + */ public void clearSettings() { settings.clear(); } @@ -308,8 +319,7 @@ public class StandardServiceRegistryBuilder { * * @return this, for method chaining */ - @SuppressWarnings({"UnusedDeclaration"}) - public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) { + public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) { initiators.add( initiator ); return this; } @@ -322,9 +332,8 @@ public class StandardServiceRegistryBuilder { * * @return this, for method chaining */ - @SuppressWarnings({"unchecked"}) - public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) { - providedServices.add( new ProvidedService( serviceRole, service ) ); + public StandardServiceRegistryBuilder addService(final Class serviceRole, final T service) { + providedServices.add( new ProvidedService<>( serviceRole, service ) ); return this; } @@ -362,12 +371,11 @@ public class StandardServiceRegistryBuilder { * * @return The StandardServiceRegistry. */ - @SuppressWarnings("unchecked") public StandardServiceRegistry build() { applyServiceContributingIntegrators(); applyServiceContributors(); - final Map settingsCopy = new HashMap( settings ); + final Map settingsCopy = new HashMap<>( settings ); settingsCopy.put( org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml ); ConfigurationHelper.resolvePlaceHolders( settingsCopy ); @@ -384,9 +392,9 @@ public class StandardServiceRegistryBuilder { private void applyServiceContributingIntegrators() { for ( Integrator integrator : bootstrapServiceRegistry.getService( IntegratorService.class ) .getIntegrators() ) { - if ( org.hibernate.integrator.spi.ServiceContributingIntegrator.class.isInstance( integrator ) ) { - org.hibernate.integrator.spi.ServiceContributingIntegrator.class.cast( integrator ).prepareServices( - this ); + if ( integrator instanceof org.hibernate.integrator.spi.ServiceContributingIntegrator ) { + ( (org.hibernate.integrator.spi.ServiceContributingIntegrator) integrator ) + .prepareServices(this ); } } } @@ -411,7 +419,7 @@ public class StandardServiceRegistryBuilder { * This allows code to configure the builder and access that to configure Configuration object. */ @Deprecated - public Map getSettings() { + public Map getSettings() { return settings; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java index 1a8d505c3a..bc479de7f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/internal/StandardServiceRegistryImpl.java @@ -6,7 +6,6 @@ */ package org.hibernate.boot.registry.internal; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,7 +27,7 @@ import org.hibernate.service.spi.ServiceInitiator; public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl implements StandardServiceRegistry { //Access to this field requires synchronization on -this- - private Map configurationValues; + private Map configurationValues; /** * Constructs a StandardServiceRegistryImpl. Should not be instantiated directly; use @@ -41,12 +40,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp * * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder */ - @SuppressWarnings( {"unchecked"}) public StandardServiceRegistryImpl( BootstrapServiceRegistry bootstrapServiceRegistry, - List serviceInitiators, - List providedServices, - Map configurationValues) { + List> serviceInitiators, + List> providedServices, + Map configurationValues) { this( true, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues ); } @@ -63,13 +61,12 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp * * @see org.hibernate.boot.registry.StandardServiceRegistryBuilder */ - @SuppressWarnings( {"unchecked"}) public StandardServiceRegistryImpl( boolean autoCloseRegistry, BootstrapServiceRegistry bootstrapServiceRegistry, - List serviceInitiators, - List providedServices, - Map configurationValues) { + List> serviceInitiators, + List> providedServices, + Map configurationValues) { super( bootstrapServiceRegistry, autoCloseRegistry ); this.configurationValues = configurationValues; @@ -77,15 +74,17 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp applyServiceRegistrations( serviceInitiators, providedServices ); } - private void applyServiceRegistrations(List serviceInitiators, List providedServices) { + private void applyServiceRegistrations(List> serviceInitiators, List> providedServices) { try { // process initiators - for ( ServiceInitiator initiator : serviceInitiators ) { + for ( ServiceInitiator initiator : serviceInitiators ) { createServiceBinding( initiator ); } // then, explicitly provided service instances + //noinspection rawtypes for ( ProvidedService providedService : providedServices ) { + //noinspection unchecked createServiceBinding( providedService ); } } @@ -103,27 +102,11 @@ public class StandardServiceRegistryImpl extends AbstractServiceRegistryImpl imp @Override public synchronized void configureService(ServiceBinding serviceBinding) { - if ( Configurable.class.isInstance( serviceBinding.getService() ) ) { + if ( serviceBinding.getService() instanceof Configurable ) { ( (Configurable) serviceBinding.getService() ).configure( configurationValues ); } } - /** - * Very advanced and tricky to handle: not designed for this. Intended for experiments only! - */ - public synchronized void resetAndReactivate(BootstrapServiceRegistry bootstrapServiceRegistry, - List serviceInitiators, - List providedServices, - Map configurationValues) { - if ( super.isActive() ) { - throw new IllegalStateException( "Can't reactivate an active registry!" ); - } - super.resetParent( bootstrapServiceRegistry ); - this.configurationValues = new HashMap( configurationValues ); - super.reactivate(); - applyServiceRegistrations( serviceInitiators, providedServices ); - } - @Override public synchronized void destroy() { super.destroy(); diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java index d694a325af..94776f6533 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeProviderInitiator.java @@ -21,7 +21,7 @@ public final class BytecodeProviderInitiator implements StandardServiceInitiator public static final StandardServiceInitiator INSTANCE = new BytecodeProviderInitiator(); @Override - public BytecodeProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public BytecodeProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { // TODO in 6 this will no longer use Environment, which is configured via global environment variables, // but move to a component which can be reconfigured differently in each registry. return Environment.getBytecodeProvider(); diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/ProxyFactoryFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/ProxyFactoryFactoryInitiator.java index f8e1d896a2..0c6153ea94 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/internal/ProxyFactoryFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/internal/ProxyFactoryFactoryInitiator.java @@ -27,7 +27,7 @@ public final class ProxyFactoryFactoryInitiator implements StandardServiceInitia public static final StandardServiceInitiator INSTANCE = new ProxyFactoryFactoryInitiator(); @Override - public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final BytecodeProvider bytecodeProvider = registry.getService( BytecodeProvider.class ); return bytecodeProvider.getProxyFactoryFactory(); } diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java index 067db2dec4..1d2f9f260f 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/NoCachingRegionFactory.java @@ -40,7 +40,7 @@ public class NoCachingRegionFactory implements RegionFactory { } @Override - public void start(SessionFactoryOptions settings, Map configValues) throws CacheException { + public void start(SessionFactoryOptions settings, Map configValues) throws CacheException { } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java index 7a558a148e..860ab2fd9c 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java @@ -43,7 +43,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final RegionFactory regionFactory = resolveRegionFactory( configurationValues, registry ); LOG.debugf( "Cache region factory : %s", regionFactory.getClass().getName() ); @@ -52,7 +52,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Properties p = new Properties(); p.putAll( configurationValues ); @@ -83,8 +83,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return null; } } diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java index bd8edd7858..5986250ad5 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractRegionFactory.java @@ -79,7 +79,7 @@ public abstract class AbstractRegionFactory implements RegionFactory { } @Override - public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException { + public final void start(SessionFactoryOptions settings, Map configValues) throws CacheException { if ( started.compareAndSet( false, true ) ) { synchronized (this) { this.options = settings; @@ -99,7 +99,7 @@ public abstract class AbstractRegionFactory implements RegionFactory { } } - protected abstract void prepareForUse(SessionFactoryOptions settings, Map configValues); + protected abstract void prepareForUse(SessionFactoryOptions settings, Map configValues); @Override public final void stop() { diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/RegionFactory.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/RegionFactory.java index 3133908e59..85a72ba152 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/RegionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/RegionFactory.java @@ -51,7 +51,7 @@ public interface RegionFactory extends Service, Stoppable { * considered as a sign to stop {@link org.hibernate.SessionFactory} * building. */ - void start(SessionFactoryOptions settings, Map configValues) throws CacheException; + void start(SessionFactoryOptions settings, Map configValues) throws CacheException; /** * By default should we perform "minimal puts" when using this second diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index ce96324049..2fc15eaa2b 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -165,7 +165,7 @@ public class Configuration { entityTuplizerFactory = new EntityTuplizerFactory(); interceptor = EmptyInterceptor.INSTANCE; properties = new Properties( ); - properties.putAll( standardServiceRegistryBuilder.getSettings()); + properties.putAll( standardServiceRegistryBuilder.getSettings() ); } @@ -320,7 +320,7 @@ public class Configuration { * * @param type The type to register. */ - public Configuration registerTypeOverride(BasicType type) { + public Configuration registerTypeOverride(BasicType type) { basicTypes.add( type ); return this; } @@ -865,7 +865,7 @@ public class Configuration { * @return this for method chaining */ public Configuration mergeProperties(Properties properties) { - for ( Map.Entry entry : properties.entrySet() ) { + for ( Map.Entry entry : properties.entrySet() ) { if ( this.properties.containsKey( entry.getKey() ) ) { continue; } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java index a64298399b..082f100c72 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceImpl.java @@ -29,7 +29,7 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe ConfigurationServiceImpl.class.getName() ); - private final Map settings; + private final Map settings; private ServiceRegistryImplementor serviceRegistry; /** @@ -37,13 +37,12 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe * * @param settings The map of settings */ - @SuppressWarnings( "unchecked" ) - public ConfigurationServiceImpl(Map settings) { + public ConfigurationServiceImpl(Map settings) { this.settings = Collections.unmodifiableMap( settings ); } @Override - public Map getSettings() { + public Map getSettings() { return settings; } @@ -86,7 +85,7 @@ public class ConfigurationServiceImpl implements ConfigurationService, ServiceRe Class target; if (candidate instanceof Class) { - target = (Class) candidate; + target = (Class) candidate; } else { try { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java index 7b6083ba53..dbe1a47d61 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/internal/ConfigurationServiceInitiator.java @@ -24,7 +24,7 @@ public class ConfigurationServiceInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new ConfigurationServiceImpl( configurationValues ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java index 1980b89bd0..63a9a27bb6 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/config/spi/ConfigurationService.java @@ -27,7 +27,7 @@ public interface ConfigurationService extends Service { * * @return The immutable map of config settings. */ - Map getSettings(); + Map getSettings(); /** * Get the named setting, using the specified converter. diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java index 49f9a7a9fe..85774384a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/batch/internal/BatchBuilderInitiator.java @@ -38,7 +38,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object builder = configurationValues.get( BUILDER ); if ( builder == null ) { return new BatchBuilderImpl( @@ -46,7 +46,7 @@ public class BatchBuilderInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object builder = configurationValues.get( BatchBuilderInitiator.BUILDER ); if ( builder == null ) { return new UnmodifiableBatchBuilderImpl( diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactory.java index 8037b41b7f..3da7ce944a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactory.java @@ -27,6 +27,6 @@ interface ConnectionCreatorFactory { Boolean autocommit, Integer isolation, String initSql, - Map configurationValues); + Map configurationValues); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactoryImpl.java index 598bb51cda..0d80bb17a7 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionCreatorFactoryImpl.java @@ -33,7 +33,7 @@ public class ConnectionCreatorFactoryImpl implements ConnectionCreatorFactory { Boolean autoCommit, Integer isolation, String initSql, - Map configurationValues) { + Map configurationValues) { if ( driver == null ) { return new DriverManagerConnectionCreator( serviceRegistry, diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java index aaea585385..9377a24a45 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/ConnectionProviderInitiator.java @@ -6,7 +6,6 @@ */ package org.hibernate.engine.jdbc.connections.internal; -import java.beans.BeanInfo; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.sql.Connection; @@ -27,7 +26,6 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.beans.BeanInfoHelper; -import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.service.spi.ServiceRegistryImplementor; /** @@ -94,7 +92,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { if ( configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { // nothing to do, but given the separate hierarchies have to handle this here. return null; @@ -108,7 +106,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator providerClass = (Class) explicitSetting; LOG.instantiatingExplicitConnectionProvider( providerClass.getName() ); return instantiateExplicitConnectionProvider( providerClass ); } @@ -125,7 +123,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator providerClass = strategySelector.selectStrategyImplementor( ConnectionProvider.class, providerName ); @@ -200,23 +198,21 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator injectionData = (Map) configurationValues.get( INJECTION_DATA ); if ( injectionData != null && injectionData.size() > 0 ) { final ConnectionProvider theConnectionProvider = connectionProvider; new BeanInfoHelper( connectionProvider.getClass() ).applyToBeanInfo( connectionProvider, - new BeanInfoHelper.BeanInfoDelegate() { - public void processBeanInfo(BeanInfo beanInfo) throws Exception { - final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); - for ( PropertyDescriptor descriptor : descriptors ) { - final String propertyName = descriptor.getName(); - if ( injectionData.containsKey( propertyName ) ) { - final Method method = descriptor.getWriteMethod(); - method.invoke( - theConnectionProvider, - injectionData.get( propertyName ) - ); - } + beanInfo -> { + final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); + for ( PropertyDescriptor descriptor : descriptors ) { + final String propertyName = descriptor.getName(); + if ( injectionData.containsKey( propertyName ) ) { + final Method method = descriptor.getWriteMethod(); + method.invoke( + theConnectionProvider, + injectionData.get( propertyName ) + ); } } } @@ -235,7 +231,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator providerClass) { try { return (ConnectionProvider) providerClass.newInstance(); } @@ -244,10 +240,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configValues) { + for ( String key : configValues.keySet() ) { + if ( key.startsWith( AvailableSettings.C3P0_CONFIG_PREFIX ) ) { return true; } } @@ -264,10 +259,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configValues) { + for ( String key : configValues.keySet() ) { + if ( key.startsWith( AvailableSettings.PROXOOL_CONFIG_PREFIX ) ) { return true; } } @@ -284,13 +278,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configValues) { + for ( String key : configValues.keySet() ) { + if ( key.startsWith( "hibernate.hikari." ) ) { return true; } } @@ -307,13 +297,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configValues) { + for ( String key : configValues.keySet() ) { + if ( key.startsWith( "hibernate.vibur." ) ) { return true; } } @@ -321,13 +307,9 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator configValues) { + for ( String key : configValues.keySet() ) { + if ( key.startsWith( "hibernate.agroal." ) ) { return true; } } @@ -355,19 +337,20 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator properties) { + public static Properties getConnectionProperties(Map properties) { final Properties result = new Properties(); - for ( Map.Entry entry : properties.entrySet() ) { - if ( ! ( String.class.isInstance( entry.getKey() ) ) || ! String.class.isInstance( entry.getValue() ) ) { + for ( Map.Entry entry : properties.entrySet() ) { + if ( !(entry.getKey() instanceof String) || !(entry.getValue() instanceof String) ) { continue; } final String key = (String) entry.getKey(); @@ -444,7 +427,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator settings) { return interpretIsolation( settings.get( AvailableSettings.ISOLATION ) ); } @@ -453,7 +436,7 @@ public class ConnectionProviderInitiator implements StandardServiceInitiator unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || DatasourceConnectionProviderImpl.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ); @@ -78,10 +78,10 @@ public class DatasourceConnectionProviderImpl implements ConnectionProvider, Con } @Override - public void configure(Map configValues) { + public void configure(Map configValues) { if ( this.dataSource == null ) { final Object dataSource = configValues.get( Environment.DATASOURCE ); - if ( DataSource.class.isInstance( dataSource ) ) { + if ( dataSource instanceof DataSource ) { this.dataSource = (DataSource) dataSource; } else { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java index 53de77074f..0715a8d4b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProviderImpl.java @@ -73,15 +73,14 @@ public class DriverManagerConnectionProviderImpl } @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { CONNECTIONS_MESSAGE_LOGGER.usingHibernateBuiltInConnectionPool(); PooledConnections pool = buildPool( configurationValues, serviceRegistry ); final long validationInterval = ConfigurationHelper.getLong( VALIDATION_INTERVAL, configurationValues, 30 ); - PoolState newstate = new PoolState( pool, validationInterval ); - this.state = newstate; + this.state = new PoolState( pool, validationInterval ); } - private PooledConnections buildPool(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { + private PooledConnections buildPool(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { final boolean autoCommit = ConfigurationHelper.getBoolean( AvailableSettings.AUTOCOMMIT, configurationValues, @@ -103,7 +102,7 @@ public class DriverManagerConnectionProviderImpl return pooledConnectionBuilder.build(); } - private static ConnectionCreator buildCreator(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { + private static ConnectionCreator buildCreator(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { final String url = (String) configurationValues.get( AvailableSettings.URL ); String driverClassName = (String) configurationValues.get( AvailableSettings.DRIVER ); @@ -276,7 +275,7 @@ public class DriverManagerConnectionProviderImpl } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || DriverManagerConnectionProviderImpl.class.isAssignableFrom( unwrapType ); } @@ -516,7 +515,7 @@ public class DriverManagerConnectionProviderImpl public static class Builder { private final ConnectionCreator connectionCreator; private ConnectionValidator connectionValidator; - private boolean autoCommit; + private final boolean autoCommit; private int initialSize = 1; private int minSize = 1; private int maxSize = 20; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java index f820c86e81..5e41ca3366 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/MultiTenantConnectionProviderInitiator.java @@ -38,8 +38,7 @@ public class MultiTenantConnectionProviderInitiator implements StandardServiceIn } @Override - @SuppressWarnings( {"unchecked"}) - public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public MultiTenantConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { if ( !configurationValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { // nothing to do, but given the separate hierarchies have to handle this here. return null; @@ -50,20 +49,22 @@ public class MultiTenantConnectionProviderInitiator implements StandardServiceIn // if they also specified the data source *name*, then lets assume they want // DataSourceBasedMultiTenantConnectionProviderImpl final Object dataSourceConfigValue = configurationValues.get( AvailableSettings.DATASOURCE ); - if ( String.class.isInstance( dataSourceConfigValue ) ) { + if ( dataSourceConfigValue instanceof String ) { return new DataSourceBasedMultiTenantConnectionProviderImpl(); } return null; } - if ( MultiTenantConnectionProvider.class.isInstance( configValue ) ) { + if ( configValue instanceof MultiTenantConnectionProvider ) { return (MultiTenantConnectionProvider) configValue; } else { final Class implClass; - if ( Class.class.isInstance( configValue ) ) { - implClass = (Class) configValue; + if ( configValue instanceof Class ) { + @SuppressWarnings("unchecked") + Class clazz = (Class) configValue; + implClass = clazz; } else { final String className = configValue.toString(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java index 562167a734..9f13b41002 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java @@ -22,7 +22,7 @@ import org.hibernate.service.UnknownUnwrapTypeException; */ public class UserSuppliedConnectionProviderImpl implements ConnectionProvider { @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || UserSuppliedConnectionProviderImpl.class.isAssignableFrom( unwrapType ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java index 2b2d8c5827..842923e44a 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractDataSourceBasedMultiTenantConnectionProviderImpl.java @@ -46,7 +46,7 @@ public abstract class AbstractDataSourceBasedMultiTenantConnectionProviderImpl i } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return DataSource.class.isAssignableFrom( unwrapType ) || MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java index 2e72e054c9..aa0668977c 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/spi/AbstractMultiTenantConnectionProvider.java @@ -47,7 +47,7 @@ public abstract class AbstractMultiTenantConnectionProvider implements MultiTena } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.isAssignableFrom( unwrapType ) || MultiTenantConnectionProvider.class.isAssignableFrom( unwrapType ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java index fa5b3f2464..b6f90129da 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/cursor/internal/RefCursorSupportInitiator.java @@ -24,7 +24,7 @@ public class RefCursorSupportInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new StandardRefCursorSupport(); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java index f6e4e6809b..97a1c901c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java @@ -53,7 +53,7 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS } @Override - public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException { + public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException { final Object dialectReference = configValues.get( AvailableSettings.DIALECT ); Dialect dialect = !isEmpty( dialectReference ) ? constructDialect( dialectReference, resolutionInfoSource ) : diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java index dfdf5d0bf8..1f607b2c91 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryInitiator.java @@ -29,7 +29,7 @@ public class DialectFactoryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new DialectFactoryImpl(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java index d52906ec9a..11d244de11 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectResolverInitiator.java @@ -36,7 +36,7 @@ public class DialectResolverInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final DialectResolverSet resolverSet = new DialectResolverSet(); applyCustomerResolvers( resolverSet, registry, configurationValues ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java index 19ed8de873..799f41d53d 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/spi/DialectFactory.java @@ -35,5 +35,5 @@ public interface DialectFactory extends Service { * * @throws HibernateException No dialect specified and no resolver could make the determination. */ - Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException; + Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException; } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java index ca550eecc1..03e9b1d7ef 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java @@ -47,7 +47,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final DialectFactory dialectFactory = registry.getService( DialectFactory.class ); // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value. @@ -244,7 +244,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator configValues, ServiceRegistryImplementor registry) { if ( !configValues.containsKey( AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER ) ) { ConnectionProvider connectionProvider = registry.getService( ConnectionProvider.class ); return new ConnectionProviderJdbcConnectionAccess( connectionProvider ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java index 24572f72c5..4ab3da47c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesImpl.java @@ -8,7 +8,6 @@ package org.hibernate.engine.jdbc.internal; import java.util.Map; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.LobCreationContext; @@ -45,7 +44,7 @@ public class JdbcServicesImpl implements JdbcServices, ServiceRegistryAwareServi } @Override - public void configure(Map configValues) { + public void configure(Map configValues) { this.jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); assert jdbcEnvironment != null : "JdbcEnvironment was not found!"; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java index 7393f85a8c..7e044cb6c4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcServicesInitiator.java @@ -31,7 +31,7 @@ public class JdbcServicesInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new JdbcServicesImpl(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlStatementLogger.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlStatementLogger.java index f4db58ee4f..f1c2224e1d 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlStatementLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/spi/SqlStatementLogger.java @@ -34,14 +34,14 @@ public class SqlStatementLogger { private final long logSlowQuery; /** - * Constructs a new SqlStatementLogger instance. + * Constructs a new {@code SqlStatementLogger} instance. */ public SqlStatementLogger() { this( false, false, false ); } /** - * Constructs a new SqlStatementLogger instance. + * Constructs a new {@code SqlStatementLogger} instance. * * @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param format Should we format the statements in the console and log @@ -51,7 +51,7 @@ public class SqlStatementLogger { } /** - * Constructs a new SqlStatementLogger instance. + * Constructs a new {@code SqlStatementLogger} instance. * * @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param format Should we format the statements in the console and log @@ -62,7 +62,7 @@ public class SqlStatementLogger { } /** - * Constructs a new SqlStatementLogger instance. + * Constructs a new {@code SqlStatementLogger} instance. * * @param logToStdout Should we log to STDOUT in addition to our internal logger. * @param format Should we format the statements in the console and log diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java index a6d29916a5..bfddec8f1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceImpl.java @@ -10,7 +10,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Hashtable; import java.util.Map; -import java.util.Set; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.InvalidNameException; @@ -39,14 +38,14 @@ final class JndiServiceImpl implements JndiService { JndiServiceImpl.class.getName() ); - private final Hashtable initialContextSettings; + private final Hashtable initialContextSettings; /** * Constructs a JndiServiceImpl * * @param configurationValues Map of configuration settings, some of which apply to JNDI support. */ - public JndiServiceImpl(Map configurationValues) { + public JndiServiceImpl(Map configurationValues) { this.initialContextSettings = extractJndiProperties( configurationValues ); } @@ -57,18 +56,17 @@ final class JndiServiceImpl implements JndiService { * * @return The extracted JNDI specific properties. */ - @SuppressWarnings({ "unchecked" }) - private static Hashtable extractJndiProperties(Map configurationValues) { - final Hashtable jndiProperties = new Hashtable(); + private static Hashtable extractJndiProperties(Map configurationValues) { + final Hashtable jndiProperties = new Hashtable<>(); - for ( Map.Entry entry : (Set) configurationValues.entrySet() ) { - if ( !String.class.isInstance( entry.getKey() ) ) { + for ( Map.Entry entry : configurationValues.entrySet() ) { + if ( !(entry.getKey() instanceof String) ) { continue; } final String propertyName = (String) entry.getKey(); final Object propertyValue = entry.getValue(); if ( propertyName.startsWith( Environment.JNDI_PREFIX ) ) { - // write the IntialContextFactory class and provider url to the result only if they are + // write the InitialContextFactory class and provider url to the result only if they are // non-null; this allows the environmental defaults (if any) to remain in effect if ( Environment.JNDI_CLASS.equals( propertyName ) ) { if ( propertyValue != null ) { @@ -81,8 +79,8 @@ final class JndiServiceImpl implements JndiService { } } else { - final String passThruPropertyname = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 ); - jndiProperties.put( passThruPropertyname, propertyValue ); + final String passThruPropertyName = propertyName.substring( Environment.JNDI_PREFIX.length() + 1 ); + jndiProperties.put( passThruPropertyName, propertyValue ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java index 2f61408894..5bd91b5ab0 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jndi/internal/JndiServiceInitiator.java @@ -29,7 +29,7 @@ public final class JndiServiceInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new JndiServiceImpl( configurationValues ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java index 374428b403..eeb0b6cad9 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/AbstractJtaPlatform.java @@ -49,7 +49,7 @@ public abstract class AbstractJtaPlatform protected abstract TransactionManager locateTransactionManager(); protected abstract UserTransaction locateUserTransaction(); - public void configure(Map configValues) { + public void configure(Map configValues) { cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java index b8d08c7d93..c808ded97e 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformInitiator.java @@ -34,8 +34,7 @@ public class JtaPlatformInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM ); JtaPlatform platform = registry.getService( StrategySelector.class ).resolveStrategy( JtaPlatform.class, setting ); @@ -53,7 +52,7 @@ public class JtaPlatformInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return null; } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformResolverInitiator.java index b5ed41c839..4e7a0ad990 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/transaction/jta/platform/internal/JtaPlatformResolverInitiator.java @@ -25,7 +25,7 @@ public class JtaPlatformResolverInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object setting = configurationValues.get( AvailableSettings.JTA_PLATFORM_RESOLVER ); final JtaPlatformResolver resolver = registry.getService( StrategySelector.class ) .resolveStrategy( JtaPlatformResolver.class, setting ); diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/EntityCopyObserverFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/event/internal/EntityCopyObserverFactoryInitiator.java index dd08ff01c2..e2f2957040 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/EntityCopyObserverFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/EntityCopyObserverFactoryInitiator.java @@ -32,7 +32,7 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityCopyObserverFactoryInitiator.class ); @Override - public EntityCopyObserverFactory initiateService(final Map configurationValues, final ServiceRegistryImplementor registry) { + public EntityCopyObserverFactory initiateService(final Map configurationValues, final ServiceRegistryImplementor registry) { final Object value = getConfigurationValue( configurationValues ); if ( value.equals( EntityCopyNotAllowedObserver.SHORT_NAME ) || value.equals( EntityCopyNotAllowedObserver.class.getName() ) ) { LOG.debugf( "Configured EntityCopyObserver strategy: %s", EntityCopyNotAllowedObserver.SHORT_NAME ); @@ -51,13 +51,13 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia //this might look excessive, but it also happens to test eagerly (at boot) that we can actually construct these //and that they are indeed of the right type. EntityCopyObserver exampleInstance = registry.getService( StrategySelector.class ).resolveStrategy( EntityCopyObserver.class, value ); - Class observerType = exampleInstance.getClass(); + Class observerType = exampleInstance.getClass(); LOG.debugf( "Configured EntityCopyObserver is a custom implementation of type %s", observerType.getName() ); return new EntityObserversFactoryFromClass( observerType ); } } - private Object getConfigurationValue(final Map configurationValues) { + private Object getConfigurationValue(final Map configurationValues) { final Object o = configurationValues.get( AvailableSettings.MERGE_ENTITY_COPY_OBSERVER ); if ( o == null ) { return EntityCopyNotAllowedObserver.SHORT_NAME; //default @@ -77,9 +77,9 @@ public class EntityCopyObserverFactoryInitiator implements StandardServiceInitia private static class EntityObserversFactoryFromClass implements EntityCopyObserverFactory { - private final Class value; + private final Class value; - public EntityObserversFactoryFromClass(Class value) { + public EntityObserversFactoryFromClass(Class value) { this.value = value; } diff --git a/hibernate-core/src/main/java/org/hibernate/exception/spi/Configurable.java b/hibernate-core/src/main/java/org/hibernate/exception/spi/Configurable.java index 548187de56..bbbe8082ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/exception/spi/Configurable.java +++ b/hibernate-core/src/main/java/org/hibernate/exception/spi/Configurable.java @@ -11,8 +11,9 @@ import java.util.Properties; import org.hibernate.HibernateException; /** - * The Configurable interface defines the contract for SQLExceptionConverter impls that - * want to be configured prior to usage given the currently defined Hibernate properties. + * This interface defines the contract for {@link SQLExceptionConverter} + * implementations that want to be configured prior to usage given the + * currently defined Hibernate properties. * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/exception/spi/SQLExceptionConverter.java b/hibernate-core/src/main/java/org/hibernate/exception/spi/SQLExceptionConverter.java index 474ae9c301..1e8650617e 100644 --- a/hibernate-core/src/main/java/org/hibernate/exception/spi/SQLExceptionConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/exception/spi/SQLExceptionConverter.java @@ -12,15 +12,14 @@ import java.sql.SQLException; import org.hibernate.JDBCException; /** - * Defines a contract for implementations that know how to convert a SQLException - * into Hibernate's JDBCException hierarchy. Inspired by Spring's - * SQLExceptionTranslator. + * Defines a contract for implementations that know how to convert a + * {@link SQLException} to Hibernate's {@link JDBCException} hierarchy. *

* Implementations must have a constructor which takes a * {@link ViolatedConstraintNameExtractor} parameter. *

- * Implementations may implement {@link Configurable} if they need to perform - * configuration steps prior to first use. + * Implementations may implement {@link Configurable} if they need to + * perform configuration steps prior to first use. * * @author Steve Ebersole */ @@ -31,7 +30,11 @@ public interface SQLExceptionConverter extends Serializable { * @param sqlException The SQLException to be converted. * @param message An optional error message. * @return The resulting JDBCException. - * @see org.hibernate.exception.ConstraintViolationException , JDBCConnectionException, SQLGrammarException, LockAcquisitionException + * + * @see org.hibernate.exception.ConstraintViolationException + * @see org.hibernate.exception.JDBCConnectionException + * @see org.hibernate.exception.SQLGrammarException + * @see org.hibernate.exception.LockAcquisitionException */ JDBCException convert(SQLException sqlException, String message, String sql); } diff --git a/hibernate-core/src/main/java/org/hibernate/exception/spi/ViolatedConstraintNameExtractor.java b/hibernate-core/src/main/java/org/hibernate/exception/spi/ViolatedConstraintNameExtractor.java index a0476e6d57..644f7cc6d4 100644 --- a/hibernate-core/src/main/java/org/hibernate/exception/spi/ViolatedConstraintNameExtractor.java +++ b/hibernate-core/src/main/java/org/hibernate/exception/spi/ViolatedConstraintNameExtractor.java @@ -10,7 +10,8 @@ import java.sql.SQLException; /** * Defines a contract for implementations that can extract the name of a violated - * constraint from a SQLException that is the result of that constraint violation. + * constraint from a {@link SQLException} that is the result of that constraint + * violation. * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/PropertiesHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/PropertiesHelper.java new file mode 100644 index 0000000000..cf0a61f657 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/PropertiesHelper.java @@ -0,0 +1,24 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.internal.util; + +import java.util.Map; +import java.util.Properties; + +public class PropertiesHelper { + + /** + * Pretend that a {@link Properties} object is really a + * {@link Map Map<String,Object>}, which of course it + * should be anyway. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public static Map map(Properties properties) { + //yup, I'm really doing this, and yep, I know it's rubbish: + return (Map) properties; + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java b/hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java index 8afd2604b6..5548a85ca5 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java @@ -55,25 +55,25 @@ public class HibernatePersistenceProvider implements PersistenceProvider { return builder.build(); } - protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) { + protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties) { return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, null ); } - protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, + protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, ClassLoader providedClassLoader) { return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, providedClassLoader, null ); } - protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, + protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, ClassLoaderService providedClassLoaderService) { return getEntityManagerFactoryBuilderOrNull( persistenceUnitName, properties, null, providedClassLoaderService ); } - private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, + private EntityManagerFactoryBuilder getEntityManagerFactoryBuilderOrNull(String persistenceUnitName, Map properties, ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService) { log.tracef( "Attempting to obtain correct EntityManagerFactoryBuilder for persistenceUnitName : %s", persistenceUnitName ); - final Map integration = wrap( properties ); + final Map integration = wrap( properties ); final List units; try { units = PersistenceXmlParser.locatePersistenceUnits( integration ); @@ -124,8 +124,7 @@ public class HibernatePersistenceProvider implements PersistenceProvider { return null; } - @SuppressWarnings("unchecked") - protected static Map wrap(Map properties) { + protected static Map wrap(Map properties) { return properties == null ? Collections.emptyMap() : Collections.unmodifiableMap( properties ); } @@ -166,17 +165,17 @@ public class HibernatePersistenceProvider implements PersistenceProvider { return true; } - protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map integration) { + protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitInfo info, Map integration) { return Bootstrap.getEntityManagerFactoryBuilder( info, integration ); } protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, - Map integration, ClassLoader providedClassLoader) { + Map integration, ClassLoader providedClassLoader) { return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoader ); } protected EntityManagerFactoryBuilder getEntityManagerFactoryBuilder(PersistenceUnitDescriptor persistenceUnitDescriptor, - Map integration, ClassLoaderService providedClassLoaderService) { + Map integration, ClassLoaderService providedClassLoaderService) { return Bootstrap.getEntityManagerFactoryBuilder( persistenceUnitDescriptor, integration, providedClassLoaderService ); } diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index e2d3e5b93c..dce6fd91c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -59,6 +59,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.EntityManagerMessageLogger; import org.hibernate.internal.util.NullnessHelper; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder; @@ -166,7 +167,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // things built in first phase, needed for second phase - private final Map configurationValues; + private final Map configurationValues; private final StandardServiceRegistry standardServiceRegistry; private final ManagedResources managedResources; private final MetadataBuilderImplementor metamodelBuilder; @@ -184,20 +185,20 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil public EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings) { + Map integrationSettings) { this( persistenceUnit, integrationSettings, null, null, null ); } public EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings, + Map integrationSettings, ClassLoader providedClassLoader ) { this( persistenceUnit, integrationSettings, providedClassLoader, null, null ); } public EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings, + Map integrationSettings, ClassLoaderService providedClassLoaderService ) { this( persistenceUnit, integrationSettings, null, providedClassLoaderService, null ); } @@ -208,14 +209,14 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil @Internal public EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnitDescriptor, - Map integration, + Map integration, Consumer mergedSettingsBaseline) { this( persistenceUnitDescriptor, integration, null, null, mergedSettingsBaseline ); } private EntityManagerFactoryBuilderImpl( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings, + Map integrationSettings, ClassLoader providedClassLoader, ClassLoaderService providedClassLoaderService, Consumer mergedSettingsBaseline) { @@ -514,7 +515,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil private MergedSettings mergeSettings( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings, + Map integrationSettings, StandardServiceRegistryBuilder ssrBuilder, Consumer mergedSettingsBaseline) { final MergedSettings mergedSettings = new MergedSettings(); @@ -541,17 +542,17 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // 2) additional cache region declarations // // we will also clean up any references with null entries - Iterator> itr = mergedSettings.configurationValues.entrySet().iterator(); + Iterator> itr = mergedSettings.configurationValues.entrySet().iterator(); while ( itr.hasNext() ) { - final Map.Entry entry = itr.next(); + final Map.Entry entry = itr.next(); if ( entry.getValue() == null ) { // remove entries with null values itr.remove(); break; } - if ( entry.getKey() instanceof String && entry.getValue() instanceof String) { - final String keyString = (String) entry.getKey(); + if ( entry.getValue() instanceof String) { + final String keyString = entry.getKey(); final String valueString = (String) entry.getValue(); if ( keyString.startsWith( CLASS_CACHE_PREFIX ) ) { @@ -584,10 +585,10 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil */ private void normalizeSettings( PersistenceUnitDescriptor persistenceUnit, - Map integrationSettings, + Map integrationSettings, MergedSettings mergedSettings) { // make a copy so we can remove things as we process them - final HashMap integrationSettingsCopy = new HashMap<>( integrationSettings ); + final HashMap integrationSettingsCopy = new HashMap<>( integrationSettings ); normalizeConnectionAccessUserAndPass( integrationSettingsCopy, mergedSettings ); @@ -630,7 +631,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // // NOTE that this occurs after the specialized normalize calls above which remove // any specially-handled settings. - for ( Map.Entry entry : integrationSettingsCopy.entrySet() ) { + for ( Map.Entry entry : integrationSettingsCopy.entrySet() ) { if ( entry.getKey() == null ) { continue; } @@ -1515,7 +1516,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil } public static class MergedSettings { - private final Map configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 ); + private final Map configurationValues = new ConcurrentHashMap<>( 16, 0.75f, 1 ); private List cacheRegionDefinitions; @@ -1523,12 +1524,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil * MergedSettings is initialized with hibernate.properties */ private MergedSettings() { - configurationValues.putAll( Environment.getProperties() ); + configurationValues.putAll( PropertiesHelper.map( Environment.getProperties() ) ); } public void processPersistenceUnitDescriptorProperties(PersistenceUnitDescriptor persistenceUnit) { if ( persistenceUnit.getProperties() != null ) { - configurationValues.putAll( persistenceUnit.getProperties() ); + configurationValues.putAll( PropertiesHelper.map( persistenceUnit.getProperties() ) ); } configurationValues.put( PERSISTENCE_UNIT_NAME, persistenceUnit.getName() ); @@ -1551,7 +1552,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil configurationValues.putAll( loadedConfig.getConfigurationValues() ); } - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java index 3d683c4c06..f3922d34c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterClassResolverInitiator.java @@ -27,14 +27,13 @@ public class PersisterClassResolverInitiator implements StandardServiceInitiator } @Override - @SuppressWarnings( {"unchecked"}) - public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object customImpl = configurationValues.get( IMPL_NAME ); if ( customImpl == null ) { return new StandardPersisterClassResolver(); } - if ( PersisterClassResolver.class.isInstance( customImpl ) ) { + if ( customImpl instanceof PersisterClassResolver ) { return (PersisterClassResolver) customImpl; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java index 565e50e473..4af2f1211f 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryInitiator.java @@ -28,18 +28,18 @@ public class PersisterFactoryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object customImpl = configurationValues.get( IMPL_NAME ); if ( customImpl == null ) { return new PersisterFactoryImpl(); } - if ( PersisterFactory.class.isInstance( customImpl ) ) { + if ( customImpl instanceof PersisterFactory ) { return (PersisterFactory) customImpl; } - final Class customImplClass = Class.class.isInstance( customImpl ) + @SuppressWarnings("unchecked") + final Class customImplClass = customImpl instanceof Class ? ( Class ) customImpl : locate( registry, customImpl.toString() ); try { diff --git a/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessStrategyResolverInitiator.java b/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessStrategyResolverInitiator.java index 809caa6c23..6ad3851ff4 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessStrategyResolverInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessStrategyResolverInitiator.java @@ -27,7 +27,7 @@ public class PropertyAccessStrategyResolverInitiator implements StandardServiceI } @Override - public PropertyAccessStrategyResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public PropertyAccessStrategyResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return new PropertyAccessStrategyResolverStandardImpl( registry ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractCommonQueryContract.java b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractCommonQueryContract.java index c079c53f08..7c6dc0807a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractCommonQueryContract.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractCommonQueryContract.java @@ -240,7 +240,6 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract return this; } - @SuppressWarnings("deprecation") public final boolean applyHint(String hintName, Object value) { getSession().checkOpen( true ); @@ -632,13 +631,12 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract setHibernateFlushMode( FlushModeTypeHelper.getFlushMode( flushModeType ) ); } - @SuppressWarnings( "rawtypes" ) - public boolean applyTupleTransformer(TupleTransformer transformer) { + public boolean applyTupleTransformer(TupleTransformer transformer) { getQueryOptions().setTupleTransformer( transformer ); return true; } - public boolean applyResultListTransformer(ResultListTransformer transformer) { + public boolean applyResultListTransformer(ResultListTransformer transformer) { getQueryOptions().setResultListTransformer( transformer ); return true; } @@ -649,7 +647,7 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract protected abstract ParameterMetadataImplementor getParameterMetadata(); - @SuppressWarnings( {"unchecked", "rawtypes"} ) + @SuppressWarnings({"unchecked", "rawtypes"}) public Set> getParameters() { getSession().checkOpen( false ); return (Set) getParameterMetadata().getRegistrations(); @@ -1394,7 +1392,7 @@ public abstract class AbstractCommonQueryContract implements CommonQueryContract } @Override - public CommonQueryContract setProperties(Map map) { + public CommonQueryContract setProperties(@SuppressWarnings("rawtypes") Map map) { for ( String paramName : getParameterMetadata().getNamedParameterNames() ) { final Object object = map.get( paramName ); if ( object == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ContainedBeanImplementor.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ContainedBeanImplementor.java index d71944f261..66428d9b5e 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ContainedBeanImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ContainedBeanImplementor.java @@ -7,7 +7,7 @@ package org.hibernate.resource.beans.container.spi; /** - * Release-able extension to ContainedBean. We make the split to make it + * Release-able extension to {@link ContainedBean}. We make the split to make it * clear that generally speaking the callers to BeanContainer should not perform * the release * diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ExtendedBeanManager.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ExtendedBeanManager.java index 325e5d2705..fbcf25e45c 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ExtendedBeanManager.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/spi/ExtendedBeanManager.java @@ -11,7 +11,7 @@ import jakarta.enterprise.inject.spi.BeanManager; /** * This contract and the nested LifecycleListener contract represent the changes * we'd like to propose to the CDI spec. The idea being simply to allow contextual - * registration of BeanManager lifecycle callbacks + * registration of {@link BeanManager} lifecycle callbacks * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBean.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBean.java index da264a4e69..075d168ae5 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBean.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBean.java @@ -7,7 +7,7 @@ package org.hibernate.resource.beans.spi; /** - * Generalized contract for a "ManagedBean" as seen by Hibernate + * Generalized contract for a (CDI or Spring) "managed bean" as seen by Hibernate * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistry.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistry.java index 7b61a0ff7f..d5d03221db 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistry.java @@ -10,7 +10,7 @@ import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.service.Service; /** - * A registry for ManagedBean instances. Responsible for managing the lifecycle. + * A registry for {@link ManagedBean} instances. Responsible for managing the lifecycle. *

* Access to the beans and usage of them are only valid between the time * the registry is initialized and released (however those events are recognized). diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistryInitiator.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistryInitiator.java index b531e81992..56be372157 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ManagedBeanRegistryInitiator.java @@ -22,7 +22,7 @@ import org.hibernate.resource.beans.internal.ManagedBeanRegistryImpl; import org.hibernate.service.spi.ServiceRegistryImplementor; /** - * Hibernate's standard initializer for the ManagedBeanRegistry service. + * Hibernate's standard initializer for the {@link ManagedBeanRegistry} service. * * Produces a {@link ManagedBeanRegistryImpl} * @@ -41,12 +41,12 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor serviceRegistry) { return new ManagedBeanRegistryImpl( resolveBeanContainer( configurationValues, serviceRegistry ) ); } - private BeanContainer resolveBeanContainer(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { + private BeanContainer resolveBeanContainer(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); final ConfigurationService cfgSvc = serviceRegistry.getService( ConfigurationService.class ); @@ -92,14 +92,14 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator containerClass; if ( explicitSetting instanceof Class ) { - containerClass = (Class) explicitSetting; + containerClass = (Class) explicitSetting; } else { final String name = explicitSetting.toString(); // try the StrategySelector service - final Class selected = serviceRegistry.getService( StrategySelector.class ) + final Class selected = serviceRegistry.getService( StrategySelector.class ) .selectStrategyImplementor( BeanContainer.class, name ); if ( selected != null ) { containerClass = selected; @@ -128,7 +128,7 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator cdiBeanManagerClass(ClassLoaderService classLoaderService) throws ClassLoadingException { try { return classLoaderService.classForName( "jakarta.enterprise.inject.spi.BeanManager" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ProvidedInstanceManagedBeanImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ProvidedInstanceManagedBeanImpl.java index e7f68ce0aa..ec608e764a 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ProvidedInstanceManagedBeanImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/spi/ProvidedInstanceManagedBeanImpl.java @@ -7,7 +7,7 @@ package org.hibernate.resource.beans.spi; /** - * ManagedBean implementation for cases where we have been handed an actual + * {@link ManagedBean} implementation for cases where we have been handed an actual * instance to use. * * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/resource/transaction/internal/TransactionCoordinatorBuilderInitiator.java b/hibernate-core/src/main/java/org/hibernate/resource/transaction/internal/TransactionCoordinatorBuilderInitiator.java index d7d6dbbed4..c381915089 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/transaction/internal/TransactionCoordinatorBuilderInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/transaction/internal/TransactionCoordinatorBuilderInitiator.java @@ -31,7 +31,7 @@ public class TransactionCoordinatorBuilderInitiator implements StandardServiceIn public static final TransactionCoordinatorBuilderInitiator INSTANCE = new TransactionCoordinatorBuilderInitiator(); @Override - public TransactionCoordinatorBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public TransactionCoordinatorBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return registry.getService( StrategySelector.class ).resolveDefaultableStrategy( TransactionCoordinatorBuilder.class, determineStrategySelection( configurationValues ), diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java index fd03ae695a..8576123ee7 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java @@ -47,10 +47,10 @@ public final class StandardServiceInitiators { private StandardServiceInitiators() { } - public static final List LIST = buildStandardServiceInitiatorList(); + public static final List> LIST = buildStandardServiceInitiatorList(); - private static List buildStandardServiceInitiatorList() { - final ArrayList serviceInitiators = new ArrayList<>(); + private static List> buildStandardServiceInitiatorList() { + final ArrayList> serviceInitiators = new ArrayList<>(); serviceInitiators.add( DefaultSessionFactoryBuilderInitiator.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java index bd70120c54..0d1a9ae376 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/AbstractServiceRegistryImpl.java @@ -50,31 +50,29 @@ public abstract class AbstractServiceRegistryImpl private volatile ServiceRegistryImplementor parent; private final boolean allowCrawling; - private final ConcurrentMap serviceBindingMap = new ConcurrentHashMap<>(); - private final ConcurrentMap roleXref = new ConcurrentHashMap<>(); + private final ConcurrentMap,ServiceBinding> serviceBindingMap = new ConcurrentHashMap<>(); + private final ConcurrentMap,Class> roleXref = new ConcurrentHashMap<>(); // The services stored in initializedServiceByRole are completely initialized // (i.e., configured, dependencies injected, and started) - private final ConcurrentMap initializedServiceByRole = new ConcurrentHashMap<>(); + private final ConcurrentMap,Service> initializedServiceByRole = new ConcurrentHashMap<>(); // IMPL NOTE : the list used for ordered destruction. Cannot used map above because we need to // iterate it in reverse order which is only available through ListIterator // assume 20 services for initial sizing // All access guarded by synchronization on the serviceBindingList itself. - private final List serviceBindingList = CollectionHelper.arrayList( 20 ); + private final List> serviceBindingList = CollectionHelper.arrayList( 20 ); // Guarded by synchronization on this. - private boolean autoCloseRegistry; + private final boolean autoCloseRegistry; // Guarded by synchronization on this. private Set childRegistries; private final AtomicBoolean active = new AtomicBoolean( true ); - @SuppressWarnings( {"UnusedDeclaration"}) protected AbstractServiceRegistryImpl() { this( (ServiceRegistryImplementor) null ); } - @SuppressWarnings( {"UnusedDeclaration"}) protected AbstractServiceRegistryImpl(boolean autoCloseRegistry) { this( (ServiceRegistryImplementor) null, autoCloseRegistry ); } @@ -100,7 +98,7 @@ public abstract class AbstractServiceRegistryImpl public AbstractServiceRegistryImpl( BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry) { - if ( ! ServiceRegistryImplementor.class.isInstance( bootstrapServiceRegistry ) ) { + if ( !(bootstrapServiceRegistry instanceof ServiceRegistryImplementor) ) { throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" ); } this.parent = (ServiceRegistryImplementor) bootstrapServiceRegistry; @@ -110,9 +108,8 @@ public abstract class AbstractServiceRegistryImpl this.parent.registerChild( this ); } - @SuppressWarnings({ "unchecked" }) protected void createServiceBinding(ServiceInitiator initiator) { - final ServiceBinding serviceBinding = new ServiceBinding( this, initiator ); + final ServiceBinding serviceBinding = new ServiceBinding<>( this, initiator ); serviceBindingMap.put( initiator.getServiceInitiated(), serviceBinding ); } @@ -125,25 +122,23 @@ public abstract class AbstractServiceRegistryImpl registerService( binding, providedService.getService() ); } - protected void visitServiceBindings(Consumer action) { + protected void visitServiceBindings(Consumer> action) { serviceBindingList.forEach( action ); } @Override - @SuppressWarnings( {"unchecked"}) public ServiceRegistry getParentServiceRegistry() { return parent; } @Override - @SuppressWarnings({ "unchecked" }) public ServiceBinding locateServiceBinding(Class serviceRole) { return locateServiceBinding( serviceRole, true ); } - @SuppressWarnings({ "unchecked" }) + @SuppressWarnings("unchecked") protected ServiceBinding locateServiceBinding(Class serviceRole, boolean checkParent) { - ServiceBinding serviceBinding = serviceBindingMap.get( serviceRole ); + ServiceBinding serviceBinding = (ServiceBinding) serviceBindingMap.get( serviceRole ); if ( serviceBinding == null && checkParent && parent != null ) { // look in parent serviceBinding = parent.locateServiceBinding( serviceRole ); @@ -158,32 +153,32 @@ public abstract class AbstractServiceRegistryImpl } // look for a previously resolved alternate registration - final Class alternative = roleXref.get( serviceRole ); + final Class alternative = roleXref.get( serviceRole ); if ( alternative != null ) { - return serviceBindingMap.get( alternative ); + return (ServiceBinding) serviceBindingMap.get( alternative ); } // perform a crawl looking for an alternate registration - for ( ServiceBinding binding : serviceBindingMap.values() ) { + for ( ServiceBinding binding : serviceBindingMap.values() ) { if ( serviceRole.isAssignableFrom( binding.getServiceRole() ) ) { // we found an alternate... log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); registerAlternate( serviceRole, binding.getServiceRole() ); - return binding; + return (ServiceBinding) binding; } if ( binding.getService() != null && serviceRole.isInstance( binding.getService() ) ) { // we found an alternate... log.alternateServiceRole( serviceRole.getName(), binding.getServiceRole().getName() ); registerAlternate( serviceRole, binding.getServiceRole() ); - return binding; + return (ServiceBinding) binding; } } return null; } - private void registerAlternate(Class alternate, Class target) { + private void registerAlternate(Class alternate, Class target) { roleXref.put( alternate, target ); } @@ -249,7 +244,6 @@ public abstract class AbstractServiceRegistryImpl return service; } - @SuppressWarnings( {"unchecked"}) protected R createService(ServiceBinding serviceBinding) { final ServiceInitiator serviceInitiator = serviceBinding.getServiceInitiator(); if ( serviceInitiator == null ) { @@ -280,7 +274,7 @@ public abstract class AbstractServiceRegistryImpl applyInjections( service ); - if ( ServiceRegistryAwareService.class.isInstance( service ) ) { + if ( service instanceof ServiceRegistryAwareService ) { ( (ServiceRegistryAwareService) service ).injectServices( this ); } } @@ -301,15 +295,15 @@ public abstract class AbstractServiceRegistryImpl } } - @SuppressWarnings({ "unchecked" }) private void processInjection(T service, Method injectionMethod, InjectService injectService) { final Class[] parameterTypes = injectionMethod.getParameterTypes(); - if ( parameterTypes == null || injectionMethod.getParameterCount() != 1 ) { + if ( injectionMethod.getParameterCount() != 1 ) { throw new ServiceDependencyException( "Encountered @InjectService on method with unexpected number of parameters" ); } + //noinspection rawtypes Class dependentServiceRole = injectService.serviceRole(); if ( dependentServiceRole == null || dependentServiceRole.equals( Void.class ) ) { dependentServiceRole = parameterTypes[0]; @@ -317,6 +311,7 @@ public abstract class AbstractServiceRegistryImpl // todo : because of the use of proxies, this is no longer returning null here... + //noinspection unchecked final Service dependantService = getService( dependentServiceRole ); if ( dependantService == null ) { if ( injectService.required() ) { @@ -336,9 +331,8 @@ public abstract class AbstractServiceRegistryImpl } @Override - @SuppressWarnings({ "unchecked" }) public void startService(ServiceBinding serviceBinding) { - if ( Startable.class.isInstance( serviceBinding.getService() ) ) { + if ( serviceBinding.getService() instanceof Startable ) { ( (Startable) serviceBinding.getService() ).start(); } } @@ -348,7 +342,6 @@ public abstract class AbstractServiceRegistryImpl } @Override - @SuppressWarnings( {"unchecked"}) public synchronized void destroy() { if ( active.compareAndSet( true, false ) ) { try { @@ -356,11 +349,11 @@ public abstract class AbstractServiceRegistryImpl //threads not owning the synchronization lock can't get an invalid Service: initializedServiceByRole.clear(); synchronized (serviceBindingList) { - ListIterator serviceBindingsIterator = serviceBindingList.listIterator( + ListIterator> serviceBindingsIterator = serviceBindingList.listIterator( serviceBindingList.size() ); while ( serviceBindingsIterator.hasPrevious() ) { - final ServiceBinding serviceBinding = serviceBindingsIterator.previous(); + final ServiceBinding serviceBinding = serviceBindingsIterator.previous(); serviceBinding.getLifecycleOwner().stopService( serviceBinding ); } serviceBindingList.clear(); @@ -376,7 +369,7 @@ public abstract class AbstractServiceRegistryImpl @Override public synchronized void stopService(ServiceBinding binding) { final Service service = binding.getService(); - if ( Stoppable.class.isInstance( service ) ) { + if ( service instanceof Stoppable ) { try { ( (Stoppable) service ).stop(); } @@ -430,7 +423,7 @@ public abstract class AbstractServiceRegistryImpl this.parent.deRegisterChild( this ); } if ( newParent != null ) { - if ( ! ServiceRegistryImplementor.class.isInstance( newParent ) ) { + if ( !(newParent instanceof ServiceRegistryImplementor) ) { throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" ); } this.parent = (ServiceRegistryImplementor) newParent; @@ -442,10 +435,7 @@ public abstract class AbstractServiceRegistryImpl } public synchronized void reactivate() { - if ( active.compareAndSet( false, true ) ) { - //ok - } - else { + if ( !active.compareAndSet(false, true) ) { throw new IllegalStateException( "Was not inactive, could not reactivate!" ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java index 0902612e4c..22628e7ddc 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryBuilderImpl.java @@ -23,8 +23,8 @@ import org.hibernate.service.spi.SessionFactoryServiceRegistryBuilder; public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryServiceRegistryBuilder { private final ServiceRegistryImplementor parent; - private final List initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList(); - private final List providedServices = new ArrayList<>(); + private final List> initiators = StandardSessionFactoryServiceInitiators.buildStandardServiceInitiatorList(); + private final List> providedServices = new ArrayList<>(); public SessionFactoryServiceRegistryBuilderImpl(ServiceRegistryImplementor parent) { this.parent = parent; @@ -38,8 +38,7 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS * @return this, for method chaining */ @Override - @SuppressWarnings( {"UnusedDeclaration"}) - public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator) { + public SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator) { initiators.add( initiator ); return this; } @@ -53,9 +52,8 @@ public class SessionFactoryServiceRegistryBuilderImpl implements SessionFactoryS * @return this, for method chaining */ @Override - @SuppressWarnings( {"unchecked"}) - public SessionFactoryServiceRegistryBuilder addService(final Class serviceRole, final Service service) { - providedServices.add( new ProvidedService( serviceRole, service ) ); + public SessionFactoryServiceRegistryBuilder addService(final Class serviceRole, final R service) { + providedServices.add( new ProvidedService<>( serviceRole, service ) ); return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java index 5b404ae78b..12426e146e 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryInitiator.java @@ -24,7 +24,7 @@ public class SessionFactoryServiceRegistryFactoryInitiator implements StandardSe } @Override - public SessionFactoryServiceRegistryFactoryImpl initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public SessionFactoryServiceRegistryFactoryImpl initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return new SessionFactoryServiceRegistryFactoryImpl( registry ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java index 70cfc9a06a..21f0063c6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryImpl.java @@ -35,11 +35,10 @@ public class SessionFactoryServiceRegistryImpl private final SessionFactoryOptions sessionFactoryOptions; private final SessionFactoryImplementor sessionFactory; - @SuppressWarnings({"unchecked", "rawtypes"}) public SessionFactoryServiceRegistryImpl( ServiceRegistryImplementor parent, - List initiators, - List providedServices, + List> initiators, + List> providedServices, SessionFactoryImplementor sessionFactory, SessionFactoryOptions sessionFactoryOptions) { super( parent ); @@ -48,7 +47,7 @@ public class SessionFactoryServiceRegistryImpl this.sessionFactoryOptions = sessionFactoryOptions; // for now, just use the standard initiator list - for ( SessionFactoryServiceInitiator initiator : initiators ) { + for ( SessionFactoryServiceInitiator initiator : initiators ) { // create the bindings up front to help identify to which registry services belong createServiceBinding( initiator ); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardSessionFactoryServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/internal/StandardSessionFactoryServiceInitiators.java index a76413841e..7917bcf61e 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/StandardSessionFactoryServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/StandardSessionFactoryServiceInitiators.java @@ -22,8 +22,8 @@ import org.hibernate.stat.internal.StatisticsInitiator; */ public final class StandardSessionFactoryServiceInitiators { - public static List buildStandardServiceInitiatorList() { - final ArrayList serviceInitiators = new ArrayList<>(); + public static List> buildStandardServiceInitiatorList() { + final ArrayList> serviceInitiators = new ArrayList<>(); serviceInitiators.add( StatisticsInitiator.INSTANCE ); serviceInitiators.add( CacheInitiator.INSTANCE ); diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/Configurable.java b/hibernate-core/src/main/java/org/hibernate/service/spi/Configurable.java index bf96a9fc31..51c38a683a 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/Configurable.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/Configurable.java @@ -18,5 +18,5 @@ public interface Configurable { * * @param configurationValues The configuration properties. */ - void configure(Map configurationValues); + void configure(Map configurationValues); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryBuilder.java index 464806547c..970a956b2a 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryBuilder.java @@ -12,8 +12,7 @@ import org.hibernate.service.Service; * @author Steve Ebersole */ public interface SessionFactoryServiceRegistryBuilder { - SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator); + SessionFactoryServiceRegistryBuilder addInitiator(SessionFactoryServiceInitiator initiator); - @SuppressWarnings( {"unchecked"}) - SessionFactoryServiceRegistryBuilder addService(Class serviceRole, Service service); + SessionFactoryServiceRegistryBuilder addService(Class serviceRole, R service); } diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/Wrapped.java b/hibernate-core/src/main/java/org/hibernate/service/spi/Wrapped.java index 3e6aba2813..983ea5aba2 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/Wrapped.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/Wrapped.java @@ -21,7 +21,7 @@ public interface Wrapped { * * @return True/false. */ - boolean isUnwrappableAs(Class unwrapType); + boolean isUnwrappableAs(Class unwrapType); /** * Unproxy the service proxy diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/Helper.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/Helper.java index 1dc26cc758..49d8a7c0bb 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/Helper.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/Helper.java @@ -125,7 +125,7 @@ public class Helper { } } - public static boolean interpretNamespaceHandling(Map configurationValues) { + public static boolean interpretNamespaceHandling(Map configurationValues) { //Print a warning if multiple conflicting properties are being set: int count = 0; if ( configurationValues.containsKey( AvailableSettings.HBM2DDL_CREATE_SCHEMAS ) ) { @@ -158,7 +158,7 @@ public class Helper { ); } - public static boolean interpretFormattingEnabled(Map configurationValues) { + public static boolean interpretFormattingEnabled(Map configurationValues) { return ConfigurationHelper.getBoolean( AvailableSettings.FORMAT_SQL, configurationValues, diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java index 3f876c14fc..144e60cdaf 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java @@ -9,7 +9,6 @@ package org.hibernate.tool.schema.internal; import java.sql.Connection; import java.util.Map; -import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.cfg.AvailableSettings; @@ -83,17 +82,17 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv } @Override - public SchemaCreator getSchemaCreator(Map options) { + public SchemaCreator getSchemaCreator(Map options) { return new SchemaCreatorImpl( this, getSchemaFilterProvider( options ).getCreateFilter() ); } @Override - public SchemaDropper getSchemaDropper(Map options) { + public SchemaDropper getSchemaDropper(Map options) { return new SchemaDropperImpl( this, getSchemaFilterProvider( options ).getDropFilter() ); } @Override - public SchemaMigrator getSchemaMigrator(Map options) { + public SchemaMigrator getSchemaMigrator(Map options) { if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { return new GroupedSchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() ); } @@ -103,7 +102,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv } @Override - public SchemaValidator getSchemaValidator(Map options) { + public SchemaValidator getSchemaValidator(Map options) { if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { return new GroupedSchemaValidatorImpl( this, getSchemaFilterProvider( options ).getValidateFilter() ); } @@ -112,7 +111,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv } } - private SchemaFilterProvider getSchemaFilterProvider(Map options) { + private SchemaFilterProvider getSchemaFilterProvider(Map options) { final Object configuredOption = (options == null) ? null : options.get( AvailableSettings.HBM2DDL_FILTER_PROVIDER ); @@ -123,7 +122,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv ); } - private JdbcMetadaAccessStrategy determineJdbcMetadaAccessStrategy(Map options) { + private JdbcMetadaAccessStrategy determineJdbcMetadaAccessStrategy(Map options) { return JdbcMetadaAccessStrategy.interpretSetting( options ); } @@ -144,7 +143,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv GenerationTarget[] buildGenerationTargets( TargetDescriptor targetDescriptor, JdbcContext jdbcContext, - Map options, + Map options, boolean needsAutoCommit) { final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); @@ -178,7 +177,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv GenerationTarget[] buildGenerationTargets( TargetDescriptor targetDescriptor, DdlTransactionIsolator ddlTransactionIsolator, - Map options) { + Map options) { final String scriptDelimiter = ConfigurationHelper.getString( HBM2DDL_DELIMITER, options, ";" ); final GenerationTarget[] targets = new GenerationTarget[ targetDescriptor.getTargetTypes().size() ]; @@ -215,7 +214,7 @@ public class HibernateSchemaManagementTool implements SchemaManagementTool, Serv return serviceRegistry.getService( TransactionCoordinatorBuilder.class ).buildDdlTransactionIsolator( jdbcContext ); } - public JdbcContext resolveJdbcContext(Map configurationValues) { + public JdbcContext resolveJdbcContext(Map configurationValues) { final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder( serviceRegistry ); // see if a specific connection has been provided diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java index 01e9bcbc04..3ceef871ac 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java @@ -97,7 +97,7 @@ public class SchemaCreatorImpl implements SchemaCreator { public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); - if ( !HibernateSchemaManagementTool.class.isInstance( smt ) ) { + if ( !(smt instanceof HibernateSchemaManagementTool) ) { smt = new HibernateSchemaManagementTool(); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); } @@ -382,9 +382,9 @@ public class SchemaCreatorImpl implements SchemaCreator { } // indexes - final Iterator indexItr = table.getIndexIterator(); + final Iterator indexItr = table.getIndexIterator(); while ( indexItr.hasNext() ) { - final Index index = (Index) indexItr.next(); + final Index index = indexItr.next(); checkExportIdentifier( index, exportIdentifiers ); applySqlStrings( dialect.getIndexExporter().getSqlCreateStrings( index, metadata, @@ -397,9 +397,9 @@ public class SchemaCreatorImpl implements SchemaCreator { } // unique keys - final Iterator ukItr = table.getUniqueKeyIterator(); + final Iterator ukItr = table.getUniqueKeyIterator(); while ( ukItr.hasNext() ) { - final UniqueKey uniqueKey = (UniqueKey) ukItr.next(); + final UniqueKey uniqueKey = ukItr.next(); checkExportIdentifier( uniqueKey, exportIdentifiers ); applySqlStrings( dialect.getUniqueKeyExporter().getSqlCreateStrings( uniqueKey, metadata, @@ -431,9 +431,9 @@ public class SchemaCreatorImpl implements SchemaCreator { } // foreign keys - final Iterator fkItr = table.getForeignKeyIterator(); + final Iterator fkItr = table.getForeignKeyIterator(); while ( fkItr.hasNext() ) { - final ForeignKey foreignKey = (ForeignKey) fkItr.next(); + final ForeignKey foreignKey = fkItr.next(); applySqlStrings( dialect.getForeignKeyExporter().getSqlCreateStrings( foreignKey, metadata, sqlStringGenerationContext @@ -549,7 +549,7 @@ public class SchemaCreatorImpl implements SchemaCreator { for ( String currentFile : importFiles.split( "," ) ) { final String resourceName = currentFile.trim(); - if ( resourceName != null && resourceName.isEmpty() ) { + if ( resourceName.isEmpty() ) { //skip empty resource names continue; } @@ -602,7 +602,7 @@ public class SchemaCreatorImpl implements SchemaCreator { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return Collections.emptyMap(); } @@ -647,7 +647,7 @@ public class SchemaCreatorImpl implements SchemaCreator { public void doCreation( Metadata metadata, final ServiceRegistry serviceRegistry, - final Map settings, + final Map settings, final boolean manageNamespaces, GenerationTarget... targets) { doCreation( @@ -660,7 +660,7 @@ public class SchemaCreatorImpl implements SchemaCreator { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return settings; } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java index aa11def8a9..576c73e190 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java @@ -91,7 +91,7 @@ public class SchemaDropperImpl implements SchemaDropper { public SchemaDropperImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); - if ( !HibernateSchemaManagementTool.class.isInstance( smt ) ) { + if ( !(smt instanceof HibernateSchemaManagementTool) ) { smt = new HibernateSchemaManagementTool(); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); } @@ -370,9 +370,9 @@ public class SchemaDropperImpl implements SchemaDropper { continue; } - final Iterator fks = table.getForeignKeyIterator(); + final Iterator fks = table.getForeignKeyIterator(); while ( fks.hasNext() ) { - final ForeignKey foreignKey = (ForeignKey) fks.next(); + final ForeignKey foreignKey = fks.next(); applySqlStrings( dialect.getForeignKeyExporter().getSqlDropStrings( foreignKey, metadata, sqlStringGenerationContext @@ -448,7 +448,7 @@ public class SchemaDropperImpl implements SchemaDropper { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return Collections.emptyMap(); } @@ -502,7 +502,7 @@ public class SchemaDropperImpl implements SchemaDropper { public void doDrop( Metadata metadata, final ServiceRegistry serviceRegistry, - final Map settings, + final Map settings, final boolean manageNamespaces, GenerationTarget... targets) { if ( targets == null || targets.length == 0 ) { @@ -524,7 +524,7 @@ public class SchemaDropperImpl implements SchemaDropper { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return settings; } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaManagementToolInitiator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaManagementToolInitiator.java index c9398d3866..b5ca29cf5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaManagementToolInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaManagementToolInitiator.java @@ -20,7 +20,7 @@ import org.hibernate.tool.schema.spi.SchemaManagementTool; public class SchemaManagementToolInitiator implements StandardServiceInitiator { public static final SchemaManagementToolInitiator INSTANCE = new SchemaManagementToolInitiator(); - public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL ); SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting ); if ( tool == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/script/SqlScriptExtractorInitiator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/script/SqlScriptExtractorInitiator.java index 030c626612..b8b54a3558 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/script/SqlScriptExtractorInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/script/SqlScriptExtractorInitiator.java @@ -27,7 +27,7 @@ public class SqlScriptExtractorInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { final Object explicitSettingValue = configurationValues.get( Environment.HBM2DDL_IMPORT_FILES_SQL_EXTRACTOR ); if ( explicitSettingValue == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java index 5e3646072b..c96f7bafb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java @@ -18,7 +18,7 @@ import org.hibernate.boot.model.relational.Exportable; */ @Incubating public interface ExecutionOptions { - Map getConfigurationValues(); + Map getConfigurationValues(); boolean shouldManageNamespaces(); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementTool.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementTool.java index 9fc88b8e56..c6a530b2d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementTool.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementTool.java @@ -19,10 +19,10 @@ import org.hibernate.tool.schema.internal.exec.GenerationTarget; */ @Incubating public interface SchemaManagementTool extends Service { - SchemaCreator getSchemaCreator(Map options); - SchemaDropper getSchemaDropper(Map options); - SchemaMigrator getSchemaMigrator(Map options); - SchemaValidator getSchemaValidator(Map options); + SchemaCreator getSchemaCreator(Map options); + SchemaDropper getSchemaDropper(Map options); + SchemaMigrator getSchemaMigrator(Map options); + SchemaValidator getSchemaValidator(Map options); /** * This allows to set an alternative implementation for the Database diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java index ae894857f2..e3c7249c08 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java @@ -63,7 +63,7 @@ public class SchemaManagementToolCoordinator { public static void process( final Metadata metadata, final ServiceRegistry serviceRegistry, - final Map configurationValues, + final Map configurationValues, DelayedDropRegistry delayedDropRegistry) { final Set groupings = ActionGrouping.interpret( metadata, configurationValues ); @@ -169,7 +169,7 @@ public class SchemaManagementToolCoordinator { } public static ExecutionOptions buildExecutionOptions( - final Map configurationValues, + final Map configurationValues, final ExceptionHandler exceptionHandler) { return buildExecutionOptions( configurationValues, @@ -179,7 +179,7 @@ public class SchemaManagementToolCoordinator { } public static ExecutionOptions buildExecutionOptions( - final Map configurationValues, + final Map configurationValues, final SchemaFilter schemaFilter, final ExceptionHandler exceptionHandler) { return new ExecutionOptions() { @@ -189,7 +189,7 @@ public class SchemaManagementToolCoordinator { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SafeMappingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SafeMappingTest.java index 0c7678961f..22859c3c79 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SafeMappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SafeMappingTest.java @@ -7,6 +7,7 @@ //$Id$ package org.hibernate.orm.test.annotations; + import org.junit.Test; import org.hibernate.AnnotationException; @@ -23,7 +24,7 @@ import static org.junit.Assert.fail; */ public class SafeMappingTest { @Test - public void testDeclarativeMix() throws Exception { + public void testDeclarativeMix() { Configuration cfg = new Configuration(); cfg.addAnnotatedClass( IncorrectEntity.class ); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SecuredBindingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SecuredBindingTest.java index 530d5ab67c..31e605e91e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SecuredBindingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/SecuredBindingTest.java @@ -27,7 +27,7 @@ public class SecuredBindingTest { @Test - public void testConfigurationMethods() throws Exception { + public void testConfigurationMethods() { Configuration ac = new Configuration(); Properties p = new Properties(); p.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/BeanValidationDisabledTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/BeanValidationDisabledTest.java index 4f2fbdb1db..91a2fbe8f9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/BeanValidationDisabledTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/BeanValidationDisabledTest.java @@ -50,7 +50,7 @@ public class BeanValidationDisabledTest extends BaseNonConfigCoreFunctionalTestC } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( "javax.persistence.validation.mode", "none" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLTest.java index 19a36c2b90..937d4971b3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLTest.java @@ -83,7 +83,7 @@ public class DDLTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( "javax.persistence.validation.mode", "ddl" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLWithoutCallbackTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLWithoutCallbackTest.java index 2a550aa73f..6f096d3044 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLWithoutCallbackTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/DDLWithoutCallbackTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.fail; public class DDLWithoutCallbackTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( "javax.persistence.validation.mode", "ddl" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/duplicatedgenerator/DuplicateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/duplicatedgenerator/DuplicateTest.java index e6458308d8..c1f43e04cf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/duplicatedgenerator/DuplicateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/duplicatedgenerator/DuplicateTest.java @@ -24,7 +24,7 @@ import org.junit.Test; */ public class DuplicateTest { @Test - public void testDuplicateEntityName() throws Exception { + public void testDuplicateEntityName() { Configuration cfg = new Configuration(); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); ServiceRegistry serviceRegistry = null; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/immutable/ImmutableEntityUpdateQueryHandlingModeExceptionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/immutable/ImmutableEntityUpdateQueryHandlingModeExceptionTest.java index 0553f1548b..5efa7089b8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/immutable/ImmutableEntityUpdateQueryHandlingModeExceptionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/immutable/ImmutableEntityUpdateQueryHandlingModeExceptionTest.java @@ -41,7 +41,7 @@ public class ImmutableEntityUpdateQueryHandlingModeExceptionTest extends BaseNon } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.IMMUTABLE_ENTITY_UPDATE_QUERY_HANDLING_MODE, "exception" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/namingstrategy/charset/AbstractCharsetNamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/namingstrategy/charset/AbstractCharsetNamingStrategyTest.java index c1c8b7e3f2..ffe32cfbea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/namingstrategy/charset/AbstractCharsetNamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/namingstrategy/charset/AbstractCharsetNamingStrategyTest.java @@ -21,6 +21,7 @@ import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.mapping.UniqueKey; import org.hibernate.service.ServiceRegistry; @@ -44,7 +45,7 @@ public abstract class AbstractCharsetNamingStrategyTest extends BaseUnitTestCase @Before public void setUp() { - Map properties = new HashMap<>( Environment.getProperties() ); + Map properties = PropertiesHelper.map( Environment.getProperties() ); properties.put( AvailableSettings.HBM2DDL_CHARSET_NAME, charsetName() ); serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( properties ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyTest.java index 8a04dd2082..9a151b149b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyTest.java @@ -574,7 +574,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); // needed for `#testListWithBagSemanticAndOrderBy` settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchOptimisticLockingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchOptimisticLockingTest.java index 55d2c66586..5d330753be 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchOptimisticLockingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchOptimisticLockingTest.java @@ -43,7 +43,7 @@ public class BatchOptimisticLockingTest extends } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, String.valueOf( 2 ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/OptionalSecondaryTableBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/OptionalSecondaryTableBatchTest.java index 66e3a9e8b6..9f90623c4f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/OptionalSecondaryTableBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/OptionalSecondaryTableBatchTest.java @@ -105,7 +105,7 @@ public class OptionalSecondaryTableBatchTest extends BaseNonConfigCoreFunctional } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, 5 ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/QualifiedTableNamingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/QualifiedTableNamingTest.java index 30f381e3ab..ea62f1254e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/QualifiedTableNamingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/database/qualfiedTableNaming/QualifiedTableNamingTest.java @@ -44,7 +44,7 @@ public class QualifiedTableNamingTest extends BaseNonConfigCoreFunctionalTestCas } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.DIALECT, TestDialect.class ); settings.put( AvailableSettings.CONNECTION_PROVIDER, MockedConnectionProvider.class.getName() ); @@ -119,7 +119,7 @@ public class QualifiedTableNamingTest extends BaseNonConfigCoreFunctionalTestCas @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return false; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java index 72954bbdb7..c10c45b20e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java @@ -45,7 +45,7 @@ public class XMLMappingDisabledTest extends BaseNonConfigCoreFunctionalTestCase } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.XML_MAPPING_ENABLED, "false" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/cascade/CascadeOnUninitializedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/cascade/CascadeOnUninitializedTest.java index 9cd6f681e7..59a64235bb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/cascade/CascadeOnUninitializedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/cascade/CascadeOnUninitializedTest.java @@ -52,7 +52,7 @@ public class CascadeOnUninitializedTest extends BaseNonConfigCoreFunctionalTestC } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.FORMAT_SQL, "true" ); sqlInterceptor = new SQLStatementInterceptor( settings ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BytecodeEnhancedLazyLoadingOnDeletedEntityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BytecodeEnhancedLazyLoadingOnDeletedEntityTest.java index 54d1dc892d..bac874c1e0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BytecodeEnhancedLazyLoadingOnDeletedEntityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BytecodeEnhancedLazyLoadingOnDeletedEntityTest.java @@ -43,7 +43,7 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( DEFAULT_LIST_SEMANTICS, CollectionClassification.BAG.name() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java index b604c55f25..5e2ac22102 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java @@ -50,7 +50,7 @@ public class NonRootEntityWithCacheAnnotationTest { @Test public void testCacheOnNonRootEntity() { - Map settings = new HashMap(); + Map settings = new HashMap<>(); settings.put( Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() ); settings.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java index 8930c3ebd2..ed309d675e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java @@ -48,7 +48,7 @@ public class NonRootEntityWithCacheableAnnotationTest { @Test public void testCacheableOnNonRootEntity() { - Map settings = new HashMap(); + Map settings = new HashMap<>(); settings.put( Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() ); settings.put( AvailableSettings.DEFAULT_CACHE_CONCURRENCY_STRATEGY, "read-write" ); settings.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/PersisterClassProviderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/PersisterClassProviderTest.java index 944b2491da..b87da6c08d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/PersisterClassProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/PersisterClassProviderTest.java @@ -26,7 +26,7 @@ import static org.junit.Assert.fail; */ public class PersisterClassProviderTest extends BaseUnitTestCase { @Test - public void testPersisterClassProvider() throws Exception { + public void testPersisterClassProvider() { Configuration cfg = new Configuration(); cfg.addAnnotatedClass( Gate.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connection/ConnectionCreatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connection/ConnectionCreatorTest.java index 3e89d501a3..be0a3f66a9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connection/ConnectionCreatorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connection/ConnectionCreatorTest.java @@ -39,8 +39,8 @@ public class ConnectionCreatorTest extends BaseUnitTestCase { new StandardServiceRegistryImpl( true, new BootstrapServiceRegistryImpl(), - Collections.emptyList(), - Collections.emptyList(), + Collections.emptyList(), + Collections.emptyList(), Collections.emptyMap() ) { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connection/PropertiesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connection/PropertiesTest.java index aba106adc8..7ede7c60c9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connection/PropertiesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connection/PropertiesTest.java @@ -7,6 +7,7 @@ package org.hibernate.orm.test.connection; import java.util.Properties; +import org.hibernate.internal.util.PropertiesHelper; import org.junit.Assert; import org.junit.Test; @@ -18,7 +19,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase; */ public class PropertiesTest extends BaseUnitTestCase { @Test - public void testProperties() throws Exception { + public void testProperties() { final Properties props = new Properties(); props.put("rpt.1.hibernate.dialect", "org.hibernate.dialect.DerbyDialect"); @@ -29,7 +30,7 @@ public class PropertiesTest extends BaseUnitTestCase { props.put("rpt.6.hibernate.connection.password_enc", "76f271db3661fd50082e68d4b953fbee"); props.put("hibernate.connection.create", "true"); - final Properties outputProps = ConnectionProviderInitiator.getConnectionProperties( props ); + final Properties outputProps = ConnectionProviderInitiator.getConnectionProperties( PropertiesHelper.map(props) ); Assert.assertEquals( 1, outputProps.size() ); Assert.assertEquals( "true", outputProps.get( "create" ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/AggressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/AggressiveReleaseTest.java index 5d8ef85042..43d595206e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/AggressiveReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/AggressiveReleaseTest.java @@ -41,8 +41,7 @@ import static org.junit.Assert.fail; @RequiresDialect(H2Dialect.class) public class AggressiveReleaseTest extends ConnectionManagementTestCase { @Override - @SuppressWarnings("unchecked") - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); TestingJtaBootstrap.prepare( settings ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/BasicConnectionProviderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/BasicConnectionProviderTest.java index 681f6328c7..b7a4cb2a34 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/BasicConnectionProviderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/BasicConnectionProviderTest.java @@ -34,8 +34,7 @@ public class BasicConnectionProviderTest extends ConnectionManagementTestCase { } @Override - @SuppressWarnings("unchecked") - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( Environment.CONNECTION_HANDLING, PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_HOLD.toString() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ExplicitConnectionProviderInstanceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ExplicitConnectionProviderInstanceTest.java index 17e7dd9723..68c253981c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ExplicitConnectionProviderInstanceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ExplicitConnectionProviderInstanceTest.java @@ -56,7 +56,7 @@ public class ExplicitConnectionProviderInstanceTest extends BaseUnitTestCase { } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return false; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/JdbcBatchingAgressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/JdbcBatchingAgressiveReleaseTest.java index d7ce221411..af3aa7f1e4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/JdbcBatchingAgressiveReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/JdbcBatchingAgressiveReleaseTest.java @@ -49,8 +49,7 @@ public class JdbcBatchingAgressiveReleaseTest extends BaseNonConfigCoreFunctiona @Override - @SuppressWarnings("unchecked") - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); TestingJtaBootstrap.prepare( settings ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/SuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/SuppliedConnectionTest.java index f237854dfe..499783340e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/SuppliedConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/SuppliedConnectionTest.java @@ -78,8 +78,7 @@ public class SuppliedConnectionTest extends ConnectionManagementTestCase { } @Override - @SuppressWarnings("unchecked") - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( Environment.CONNECTION_HANDLING, PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_HOLD.toString() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ThreadLocalCurrentSessionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ThreadLocalCurrentSessionTest.java index c72a3ff57b..e771d22f92 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ThreadLocalCurrentSessionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/connections/ThreadLocalCurrentSessionTest.java @@ -32,8 +32,7 @@ import static org.junit.Assert.fail; @RequiresDialect(H2Dialect.class) public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase { @Override - @SuppressWarnings("unchecked") - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( Environment.CURRENT_SESSION_CONTEXT_CLASS, TestableThreadLocalContext.class.getName() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/MariaDBExtractSequenceMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/MariaDBExtractSequenceMetadataTest.java index 0049e1325d..2ed9947947 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/MariaDBExtractSequenceMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/MariaDBExtractSequenceMetadataTest.java @@ -51,7 +51,8 @@ public class MariaDBExtractSequenceMetadataTest { @Test @TestForIssue(jiraKey = "HHH-13373") public void testHibernateLaunchedSuccessfully() { - JdbcEnvironment jdbcEnvironment = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties()).getService( JdbcEnvironment.class ); + JdbcEnvironment jdbcEnvironment = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() ) + .getService( JdbcEnvironment.class ); Assertions.assertFalse( jdbcEnvironment.getExtractedDatabaseMetaData().getSequenceInformationList().isEmpty() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/SequenceInformationMariaDBTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/SequenceInformationMariaDBTest.java index 1d039db425..e3629d2558 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/SequenceInformationMariaDBTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/functional/SequenceInformationMariaDBTest.java @@ -21,6 +21,7 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.dialect.MariaDBDialect; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; @@ -54,7 +55,7 @@ public class SequenceInformationMariaDBTest { @BeforeAll public void init() { connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( Environment.getProperties() ); + connectionProvider.configure( PropertiesHelper.map( Environment.getProperties() ) ); try(Connection connection = connectionProvider.getConnection(); Statement statement = connection.createStatement()) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/resolver/DialectFactoryTest.java index 268590d359..ff4ef72b37 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/resolver/DialectFactoryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/resolver/DialectFactoryTest.java @@ -61,7 +61,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { @Test public void testExplicitShortNameUse() { - final Map configValues = new HashMap(); + final Map configValues = new HashMap<>(); configValues.put( Environment.DIALECT, "H2" ); assertEquals( H2Dialect.class, dialectFactory.buildDialect( configValues, null ).getClass() ); @@ -72,7 +72,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { @Test public void testExplicitlySuppliedDialectClassName() { - final Map configValues = new HashMap(); + final Map configValues = new HashMap<>(); configValues.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); assertEquals( HSQLDialect.class, dialectFactory.buildDialect( configValues, null ).getClass() ); @@ -98,17 +98,17 @@ public class DialectFactoryTest extends BaseUnitTestCase { @Test public void testBuildDialectByProperties() { - Properties props = new Properties(); try { - dialectFactory.buildDialect( props, null ); + dialectFactory.buildDialect( new HashMap<>(), null ); fail(); } catch ( HibernateException e ) { assertNull( e.getCause() ); } - props.setProperty( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); + Map props = new HashMap<>(); + props.put( Environment.DIALECT, "org.hibernate.dialect.HSQLDialect" ); assertEquals( HSQLDialect.class, dialectFactory.buildDialect( props, null ).getClass() ); } @@ -242,7 +242,7 @@ public class DialectFactoryTest extends BaseUnitTestCase { DialectResolver resolver) { dialectFactory.setDialectResolver( resolver ); Dialect resolved = dialectFactory.buildDialect( - new Properties(), + new HashMap<>(), new DialectResolutionInfoSource() { @Override public DialectResolutionInfo getDialectResolutionInfo() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseExceptionHandlingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseExceptionHandlingTest.java index 15fcee735b..a99088b7f6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseExceptionHandlingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseExceptionHandlingTest.java @@ -34,5 +34,5 @@ public abstract class BaseExceptionHandlingTest extends BaseJpaOrNativeBootstrap } @Override - protected void configure(Map properties) {} + protected void configure(Map properties) {} } \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseJpaOrNativeBootstrapFunctionalTestCase.java b/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseJpaOrNativeBootstrapFunctionalTestCase.java index a299d4e225..e40956e74f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseJpaOrNativeBootstrapFunctionalTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/exceptionhandling/BaseJpaOrNativeBootstrapFunctionalTestCase.java @@ -28,6 +28,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jpa.HibernatePersistenceProvider; import org.hibernate.jpa.boot.spi.Bootstrap; @@ -283,7 +284,7 @@ public abstract class BaseJpaOrNativeBootstrapFunctionalTestCase extends BaseUni properties.put( AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(), entry.getValue() ); } - configure( properties ); + configure( PropertiesHelper.map( properties ) ); if ( createSchema() ) { properties.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" ); @@ -293,7 +294,7 @@ public abstract class BaseJpaOrNativeBootstrapFunctionalTestCase extends BaseUni return properties; } - protected void configure(Map properties) { + protected void configure(Map properties) { } protected static final Class[] NO_CLASSES = new Class[0]; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/filter/DynamicFilterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/filter/DynamicFilterTest.java index 1141283359..e131ada1db 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/filter/DynamicFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/filter/DynamicFilterTest.java @@ -88,7 +88,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - public void addSettings(Map settings) { + public void addSettings(Map settings) { settings.put( AvailableSettings.MAX_FETCH_DEPTH, "1" ); settings.put( AvailableSettings.GENERATE_STATISTICS, "true" ); settings.put( AvailableSettings.USE_QUERY_CACHE, "true" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/flush/TestFlushJoinTransaction.java b/hibernate-core/src/test/java/org/hibernate/orm/test/flush/TestFlushJoinTransaction.java index d9bb9151b5..80048d80fc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/flush/TestFlushJoinTransaction.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/flush/TestFlushJoinTransaction.java @@ -28,7 +28,7 @@ import static org.junit.Assert.fail; public class TestFlushJoinTransaction extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/sequence/PostgreSQLIdentitySequenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/sequence/PostgreSQLIdentitySequenceTest.java index f89b185bdb..6777a97640 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/sequence/PostgreSQLIdentitySequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/sequence/PostgreSQLIdentitySequenceTest.java @@ -20,6 +20,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; @@ -46,7 +47,7 @@ public class PostgreSQLIdentitySequenceTest { @BeforeAll public void produceEntityManagerFactory() throws SQLException { connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( Environment.getProperties() ); + connectionProvider.configure( PropertiesHelper.map( Environment.getProperties() ) ); try (Connection connection = connectionProvider.getConnection(); Statement statement = connection.createStatement()) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/interceptor/InterceptorNonNullTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/interceptor/InterceptorNonNullTransactionTest.java index 16de98a16f..e1ed4d64a0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/interceptor/InterceptorNonNullTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/interceptor/InterceptorNonNullTransactionTest.java @@ -32,7 +32,7 @@ import org.junit.runners.Parameterized; public class InterceptorNonNullTransactionTest extends BaseJpaOrNativeBootstrapFunctionalTestCase { public enum JpaComplianceTransactionSetting { DEFAULT, TRUE, FALSE } - public enum JtaAllowTransactionAccessSetting { DEFAULT, TRUE, FALSE; }; + public enum JtaAllowTransactionAccessSetting { DEFAULT, TRUE, FALSE } @Parameterized.Parameters(name = "Bootstrap={0}, JpaComplianceTransactionSetting={1}, JtaAllowTransactionAccessSetting={2}") public static Iterable parameters() { @@ -72,7 +72,7 @@ public class InterceptorNonNullTransactionTest extends BaseJpaOrNativeBootstrapF } @Override - protected void configure(Map properties) { + protected void configure(Map properties) { super.configure( properties ); switch ( jpaComplianceTransactionSetting ) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/SessionJdbcBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/SessionJdbcBatchTest.java index ac2084b836..4ef9f6635b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/SessionJdbcBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/SessionJdbcBatchTest.java @@ -42,7 +42,7 @@ public class SessionJdbcBatchTest } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.STATEMENT_BATCH_SIZE, 2 ); connectionProvider.setConnectionProvider( (ConnectionProvider) settings.get( AvailableSettings.CONNECTION_PROVIDER ) ); settings.put( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/PreUpdateCustomEntityDirtinessStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/PreUpdateCustomEntityDirtinessStrategyTest.java index 5485ad77d5..dcd9756672 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/PreUpdateCustomEntityDirtinessStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/callbacks/PreUpdateCustomEntityDirtinessStrategyTest.java @@ -71,7 +71,7 @@ public class PreUpdateCustomEntityDirtinessStrategyTest } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.CUSTOM_ENTITY_DIRTINESS_STRATEGY, DefaultCustomEntityDirtinessStrategy.INSTANCE ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/QueryApiTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/QueryApiTest.java index 30aa499826..e66aa16e0d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/QueryApiTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/QueryApiTest.java @@ -42,7 +42,7 @@ public class QueryApiTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "true" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/CachingWithSecondaryTablesTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/CachingWithSecondaryTablesTests.java index 225a672d11..642f846519 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/CachingWithSecondaryTablesTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/CachingWithSecondaryTablesTests.java @@ -131,8 +131,8 @@ public class CachingWithSecondaryTablesTests extends BaseUnitTestCase { } - private SessionFactoryImplementor buildSessionFactory(Class entityClass, boolean strict) { - final Map settings = new HashMap(); + private SessionFactoryImplementor buildSessionFactory(Class entityClass, boolean strict) { + final Map settings = new HashMap<>(); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); settings.put( AvailableSettings.JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE ); settings.put( AvailableSettings.GENERATE_STATISTICS, "true" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/InheritedCacheableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/InheritedCacheableTest.java index 37d9ae5d5d..0f572cac37 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/InheritedCacheableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/InheritedCacheableTest.java @@ -94,7 +94,7 @@ public class InheritedCacheableTest extends BaseNonConfigCoreFunctionalTestCase } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/SubclassOnlyCachingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/SubclassOnlyCachingTests.java index 5101ae7749..def1f3b10f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/SubclassOnlyCachingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/caching/SubclassOnlyCachingTests.java @@ -82,7 +82,7 @@ public class SubclassOnlyCachingTests extends BaseNonConfigCoreFunctionalTestCas } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/ConfigurationObjectSettingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/ConfigurationObjectSettingTest.java index 55997053b9..6527f11c50 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/ConfigurationObjectSettingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/ConfigurationObjectSettingTest.java @@ -7,6 +7,7 @@ package org.hibernate.orm.test.jpa.ejb3configuration; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -311,7 +312,11 @@ public class ConfigurationObjectSettingTest { assertThat( grouping.getScriptAction() ).isEqualTo( scriptAction ); // verify also interpreting the db-name, etc... they are used by SF/EMF to resolve Dialect - final DialectResolver dialectResolver = new DialectResolverInitiator().initiateService( settings, (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().build() ); + final DialectResolver dialectResolver = new DialectResolverInitiator() + .initiateService( + new HashMap<>(settings), + (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().build() + ); final Dialect dialect = dialectResolver.resolveDialect( TestingDialectResolutionInfo.forDatabaseInfo( dbName ) ); assertThat( dialect ).isInstanceOf( H2Dialect.class ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/discriminator/DiscriminatorMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/discriminator/DiscriminatorMultiTenancyTest.java index 4dc12dec2d..14a5973c12 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/discriminator/DiscriminatorMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/discriminator/DiscriminatorMultiTenancyTest.java @@ -57,7 +57,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase { @Before public void setUp() { - Map settings = new HashMap(); + Map settings = new HashMap<>(); settings.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantResolver); settings.put(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName()); settings.put(Environment.GENERATE_STATISTICS, "true"); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/schema/AbstractSchemaBasedMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/schema/AbstractSchemaBasedMultiTenancyTest.java index 11bec296c6..1b8462f947 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/schema/AbstractSchemaBasedMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/multitenancy/schema/AbstractSchemaBasedMultiTenancyTest.java @@ -56,7 +56,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest settings = new HashMap<>(); settings.put( Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() ); settings.put( Environment.GENERATE_STATISTICS, "true" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java index 068b34b20e..bb64cbdda1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/QueryTimeOutTest.java @@ -56,7 +56,7 @@ public class QueryTimeOutTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { CONNECTION_PROVIDER.setConnectionProvider( (ConnectionProvider) settings.get( AvailableSettings.CONNECTION_PROVIDER ) ); settings.put( AvailableSettings.CONNECTION_PROVIDER, CONNECTION_PROVIDER ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/JpaComplianceAlreadyStartedTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/JpaComplianceAlreadyStartedTransactionTest.java index f5daff0b5e..f8a47231f5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/JpaComplianceAlreadyStartedTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/JpaComplianceAlreadyStartedTransactionTest.java @@ -28,7 +28,7 @@ public class JpaComplianceAlreadyStartedTransactionTest extends BaseNonConfigCor private TransactionManager tm; @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/NonJpaComplianceAlreadyStartedTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/NonJpaComplianceAlreadyStartedTransactionTest.java index e379f88fc9..ffb17bd757 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/NonJpaComplianceAlreadyStartedTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/resource/transaction/jta/NonJpaComplianceAlreadyStartedTransactionTest.java @@ -31,7 +31,7 @@ public class NonJpaComplianceAlreadyStartedTransactionTest extends BaseNonConfig private TransactionManager tm; @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/ConnectionsReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/ConnectionsReleaseTest.java index a96863dbda..5a0cc6f4d1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/ConnectionsReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/ConnectionsReleaseTest.java @@ -22,6 +22,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.tool.hbm2ddl.SchemaUpdate; import org.hibernate.tool.hbm2ddl.SchemaValidator; import org.hibernate.tool.schema.TargetType; @@ -57,7 +58,7 @@ public class ConnectionsReleaseTest extends BaseUnitTestCase { @Before public void setUp() { connectionProvider = new ConnectionProviderDecorator(); - connectionProvider.configure( getConnectionProviderProperties() ); + connectionProvider.configure( PropertiesHelper.map( getConnectionProviderProperties() ) ); ssr = new StandardServiceRegistryBuilder() .addService( ConnectionProvider.class, connectionProvider ) @@ -75,13 +76,13 @@ public class ConnectionsReleaseTest extends BaseUnitTestCase { } @Test - public void testSchemaUpdateReleasesAllConnections() throws SQLException { + public void testSchemaUpdateReleasesAllConnections() { new SchemaUpdate().execute( EnumSet.of( TargetType.DATABASE ), metadata ); assertThat( connectionProvider.getOpenConnection(), is( 0 ) ); } @Test - public void testSchemaValidatorReleasesAllConnections() throws SQLException { + public void testSchemaValidatorReleasesAllConnections() { new SchemaValidator().validate( metadata ); assertThat( connectionProvider.getOpenConnection(), is( 0 ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/service/ServiceRegistryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/service/ServiceRegistryTest.java index ec7d74d676..343c84e582 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/service/ServiceRegistryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/service/ServiceRegistryTest.java @@ -152,7 +152,7 @@ public class ServiceRegistryTest { } @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { try { Thread.sleep( TIME_TO_SLEEP ); } @@ -194,7 +194,7 @@ public class ServiceRegistryTest { } @Override - public SlowInitializationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public SlowInitializationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return new SlowInitializationService(); } } @@ -207,7 +207,7 @@ public class ServiceRegistryTest { } @Override - public FakeService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + public FakeService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return null; } } @@ -220,7 +220,7 @@ public class ServiceRegistryTest { } @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/syncSpace/NativeQuerySyncSpaceCachingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/syncSpace/NativeQuerySyncSpaceCachingTest.java index 2ebc79fcb0..44243e115d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/syncSpace/NativeQuerySyncSpaceCachingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/syncSpace/NativeQuerySyncSpaceCachingTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue; */ public class NativeQuerySyncSpaceCachingTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, true ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java index 65c0dbb9db..29f7793109 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/subclassProxyInterface/SubclassProxyInterfaceTest.java @@ -24,7 +24,7 @@ public class SubclassProxyInterfaceTest { final Configuration cfg = new Configuration() .setProperty( Environment.DIALECT, H2Dialect.class.getName() ) .addClass( Person.class ); - try (ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() )) { + try (ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ) ) { cfg.buildSessionFactory( serviceRegistry ).close(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tm/InterceptorTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tm/InterceptorTransactionTest.java index 13241dbf7c..ee42c42726 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tm/InterceptorTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tm/InterceptorTransactionTest.java @@ -112,7 +112,7 @@ public class InterceptorTransactionTest extends BaseJpaOrNativeBootstrapFunction return new Class[] { SimpleEntity.class }; } - protected void configure(Map properties) { + protected void configure(Map properties) { super.configure( properties ); TestingJtaBootstrap.prepare( properties ); properties.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DropSchemaDuringJtaTxnTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DropSchemaDuringJtaTxnTest.java index 9b78c89bc3..0de5642ea7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DropSchemaDuringJtaTxnTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DropSchemaDuringJtaTxnTest.java @@ -19,6 +19,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.orm.test.resource.transaction.jta.JtaPlatformStandardTestingImpl; @@ -29,7 +30,7 @@ import org.junit.Test; */ public class DropSchemaDuringJtaTxnTest extends BaseUnitTestCase { @Test - public void testDrop() throws Exception { + public void testDrop() { final SessionFactory sessionFactory = buildSessionFactory(); sessionFactory.close(); } @@ -47,8 +48,7 @@ public class DropSchemaDuringJtaTxnTest extends BaseUnitTestCase { } private SessionFactory buildSessionFactory() { - Map settings = new HashMap(); - settings.putAll( Environment.getProperties() ); + Map settings = new HashMap<>( PropertiesHelper.map( Environment.getProperties() ) ); TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java index 36f20c1d41..ba95a67dd3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java @@ -27,6 +27,7 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.tool.schema.internal.DefaultSchemaFilter; import org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl; @@ -55,9 +56,7 @@ import org.junit.Test; import org.jboss.logging.Logger; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; /** * @author Vlad Mihalcea @@ -86,7 +85,7 @@ public class IndividuallySchemaValidatorImplConnectionTest extends BaseUnitTestC public void setUp() throws Exception { connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( properties() ); + connectionProvider.configure( PropertiesHelper.map( properties() ) ); connection = connectionProvider.getConnection(); @@ -149,7 +148,7 @@ public class IndividuallySchemaValidatorImplConnectionTest extends BaseUnitTestC DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( properties() ); + connectionProvider.configure( PropertiesHelper.map( properties() ) ); final GenerationTargetToDatabase schemaGenerator = new GenerationTargetToDatabase( new DdlTransactionIsolatorTestingImpl( @@ -188,7 +187,7 @@ public class IndividuallySchemaValidatorImplConnectionTest extends BaseUnitTestC protected Properties properties() { Properties properties = new Properties( ); URL propertiesURL = Thread.currentThread().getContextClassLoader().getResource( "hibernate.properties" ); - try(FileInputStream inputStream = new FileInputStream( propertiesURL.getFile() )) { + try(FileInputStream inputStream = new FileInputStream( propertiesURL.getFile() ) ) { properties.load( inputStream ); } catch (IOException e) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java index a6dd8fa1f2..84df7ef7c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java @@ -25,6 +25,7 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.tool.schema.internal.DefaultSchemaFilter; import org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl; @@ -112,7 +113,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { } @Test - public void testMissingEntityContainsQualifiedEntityName() throws Exception { + public void testMissingEntityContainsQualifiedEntityName() { final MetadataSources metadataSources = new MetadataSources( ssr ); metadataSources.addAnnotatedClass( MissingEntity.class ); @@ -129,7 +130,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { } @Test - public void testMissingEntityContainsUnqualifiedEntityName() throws Exception { + public void testMissingEntityContainsUnqualifiedEntityName() { final MetadataSources metadataSources = new MetadataSources( ssr ); metadataSources.addAnnotatedClass( UnqualifiedMissingEntity.class ); @@ -146,7 +147,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { } @Test - public void testMissingColumn() throws Exception { + public void testMissingColumn() { MetadataSources metadataSources = new MetadataSources( ssr ); metadataSources.addAnnotatedClass( NoNameColumn.class ); @@ -161,7 +162,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( properties() ); + connectionProvider.configure( PropertiesHelper.map( properties() ) ); final GenerationTargetToDatabase schemaGenerator = new GenerationTargetToDatabase( new DdlTransactionIsolatorTestingImpl( @@ -201,7 +202,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { } @Test - public void testMismatchColumnType() throws Exception { + public void testMismatchColumnType() { MetadataSources metadataSources = new MetadataSources( ssr ); metadataSources.addAnnotatedClass( NameColumn.class ); @@ -216,7 +217,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( properties() ); + connectionProvider.configure( PropertiesHelper.map( properties() ) ); final GenerationTargetToDatabase schemaGenerator = new GenerationTargetToDatabase( new DdlTransactionIsolatorTestingImpl( @@ -275,7 +276,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { protected Properties properties() { Properties properties = new Properties( ); URL propertiesURL = Thread.currentThread().getContextClassLoader().getResource( "hibernate.properties" ); - try(FileInputStream inputStream = new FileInputStream( propertiesURL.getFile() )) { + try ( FileInputStream inputStream = new FileInputStream( propertiesURL.getFile() ) ) { properties.load( inputStream ); } catch (IOException e) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java index f3451352d0..715d47b7a4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/JtaPlatformLoggingTest.java @@ -40,7 +40,7 @@ public class JtaPlatformLoggingTest extends BaseNonConfigCoreFunctionalTestCase private Triggerable triggerable = logInspection.watchForLogMessages( "HHH000490" ); @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { TestingJtaBootstrap.prepare( settings ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerManyToOneFetchModeSelectWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerManyToOneFetchModeSelectWhereTest.java index ec9c04ec21..ce9a82a592 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerManyToOneFetchModeSelectWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerManyToOneFetchModeSelectWhereTest.java @@ -43,7 +43,7 @@ import static org.junit.Assert.assertSame; public class EagerManyToOneFetchModeSelectWhereTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.CREATE_EMPTY_COMPOSITES_ENABLED, true ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereDontUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereDontUseClassWhereTest.java index 102d0fd1fd..15dbbd1e31 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereDontUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereDontUseClassWhereTest.java @@ -47,7 +47,7 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "false" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereUseClassWhereTest.java index caa21436f4..7e67604e2f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/EagerToManyWhereUseClassWhereTest.java @@ -47,7 +47,7 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "true" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereDontUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereDontUseClassWhereTest.java index 388159af8b..54771e493c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereDontUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereDontUseClassWhereTest.java @@ -47,7 +47,7 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "false" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereUseClassWhereTest.java index 9497aa3f1a..7af734c01b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/annotations/LazyToManyWhereUseClassWhereTest.java @@ -47,7 +47,7 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "true" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerManyToOneFetchModeSelectWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerManyToOneFetchModeSelectWhereTest.java index 7a0e923450..97a19e61ea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerManyToOneFetchModeSelectWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerManyToOneFetchModeSelectWhereTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertSame; public class EagerManyToOneFetchModeSelectWhereTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.CREATE_EMPTY_COMPOSITES_ENABLED, true ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereDontUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereDontUseClassWhereTest.java index cc072ee47d..46eeda5e42 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereDontUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereDontUseClassWhereTest.java @@ -41,7 +41,7 @@ public class EagerToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunc } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "false" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereUseClassWhereTest.java index a87254231a..c89f82c8b6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/EagerToManyWhereUseClassWhereTest.java @@ -41,7 +41,7 @@ public class EagerToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunction } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "true" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereDontUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereDontUseClassWhereTest.java index 88e35931a6..e108423751 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereDontUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereDontUseClassWhereTest.java @@ -41,7 +41,7 @@ public class LazyToManyWhereDontUseClassWhereTest extends BaseNonConfigCoreFunct } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "false" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereUseClassWhereTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereUseClassWhereTest.java index 990da2ae77..7b07602b8c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereUseClassWhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/where/hbm/LazyToManyWhereUseClassWhereTest.java @@ -41,7 +41,7 @@ public class LazyToManyWhereUseClassWhereTest extends BaseNonConfigCoreFunctiona } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_ENTITY_WHERE_CLAUSE_FOR_COLLECTIONS, "true" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/queryhint/QueryHintHANATest.java b/hibernate-core/src/test/java/org/hibernate/test/queryhint/QueryHintHANATest.java index 54b23ee869..31ae81674d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/queryhint/QueryHintHANATest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/queryhint/QueryHintHANATest.java @@ -44,7 +44,7 @@ public class QueryHintHANATest extends BaseNonConfigCoreFunctionalTestCase { private SQLStatementInterceptor sqlStatementInterceptor; @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( AvailableSettings.USE_SQL_COMMENTS, "true" ); sqlStatementInterceptor = new SQLStatementInterceptor( settings ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/timestamp/LocalDateCustomSessionLevelTimeZoneTest.java b/hibernate-core/src/test/java/org/hibernate/test/timestamp/LocalDateCustomSessionLevelTimeZoneTest.java index ab1dfc2478..425332f4b4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/timestamp/LocalDateCustomSessionLevelTimeZoneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/timestamp/LocalDateCustomSessionLevelTimeZoneTest.java @@ -36,9 +36,9 @@ public class LocalDateCustomSessionLevelTimeZoneTest extends BaseSessionFactoryF private static final TimeZone TIME_ZONE = TimeZone.getTimeZone( "Europe/Berlin" ); - private ConnectionProviderDelegate connectionProvider = new ConnectionProviderDelegate() { + private final ConnectionProviderDelegate connectionProvider = new ConnectionProviderDelegate() { @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { String url = (String) configurationValues.get( AvailableSettings.URL ); if ( !url.contains( "?" ) ) { url += "?"; diff --git a/hibernate-core/src/test/java/org/hibernate/test/tm/CMTTest.java b/hibernate-core/src/test/java/org/hibernate/test/tm/CMTTest.java index 92e3d8219f..32a4991bc6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/tm/CMTTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/tm/CMTTest.java @@ -43,7 +43,7 @@ public class CMTTest extends BaseNonConfigCoreFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { TestingJtaBootstrap.prepare( settings ); //settings.put( AvailableSettings.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() ); settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName() ); diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java index bdda05350c..60fea845d9 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceImpl.java @@ -62,7 +62,7 @@ public class EnversServiceImpl implements EnversService, Configurable, Stoppable private EntitiesConfigurations entitiesConfigurations; @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { if ( configurationValues.containsKey( LEGACY_AUTO_REGISTER ) ) { log.debugf( "Encountered deprecated Envers setting [%s]; use [%s] or [%s] instead", diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceInitiator.java b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceInitiator.java index 67461e926d..9ec663895c 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceInitiator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/boot/internal/EnversServiceInitiator.java @@ -22,7 +22,7 @@ public class EnversServiceInitiator implements StandardServiceInitiator configurationValues, ServiceRegistryImplementor registry) { return new EnversServiceImpl(); } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java index 23de00569d..fe1291be4a 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java @@ -38,7 +38,7 @@ public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.SHOW_SQL, "true" ); diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/dynamic/AuditedDynamicComponentsAdvancedCasesTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/dynamic/AuditedDynamicComponentsAdvancedCasesTest.java index 486a9436a5..59ee66ee0f 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/dynamic/AuditedDynamicComponentsAdvancedCasesTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/dynamic/AuditedDynamicComponentsAdvancedCasesTest.java @@ -54,7 +54,7 @@ public class AuditedDynamicComponentsAdvancedCasesTest extends BaseEnversFunctio public static final String INTERNAL_LIST_OF_USER_TYPES = "internalListOfUserTypes"; @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.JPA_TRANSACTION_COMPLIANCE, "false" ); } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyDeleteTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyDeleteTest.java index acdadea41f..ea3881edf6 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyDeleteTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/manytoone/lazy/ManyToOneLazyDeleteTest.java @@ -78,7 +78,7 @@ public class ManyToOneLazyDeleteTest extends BaseEnversFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put(EnversSettings.STORE_DATA_AT_DELETE, "true"); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/AbstractOneSessionTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/AbstractOneSessionTest.java index d9a52a215c..0986ab6609 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/AbstractOneSessionTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/AbstractOneSessionTest.java @@ -14,10 +14,10 @@ import org.hibernate.MappingException; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; -import org.hibernate.cfg.Environment; import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.configuration.EnversSettings; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.AfterClassOnce; diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/BaseEnversFunctionalTestCase.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/BaseEnversFunctionalTestCase.java index 9e7946e2d4..13ce80d1ed 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/BaseEnversFunctionalTestCase.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/BaseEnversFunctionalTestCase.java @@ -72,7 +72,7 @@ public abstract class BaseEnversFunctionalTestCase extends BaseNonConfigCoreFunc } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/basic/OutsideTransactionTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/basic/OutsideTransactionTest.java index cabf4fdaa9..38e5e175ed 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/basic/OutsideTransactionTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/basic/OutsideTransactionTest.java @@ -33,7 +33,7 @@ public class OutsideTransactionTest extends BaseEnversFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( EnversSettings.STORE_DATA_AT_DELETE, "true" ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AuditedDynamicComponentTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AuditedDynamicComponentTest.java index 89268a30af..f1c74decf3 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AuditedDynamicComponentTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AuditedDynamicComponentTest.java @@ -20,8 +20,6 @@ import org.hibernate.envers.internal.tools.StringTools; import org.hibernate.envers.query.AuditEntity; import org.hibernate.orm.test.envers.BaseEnversFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; -import org.hibernate.orm.test.envers.integration.components.dynamic.AuditedDynamicComponentEntity; -import org.hibernate.orm.test.envers.integration.components.dynamic.SimpleEntity; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.ServiceRegistryBuilder; diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/query/AssociationRevisionsOfEntitiesQueryStoreAtDeletionTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/query/AssociationRevisionsOfEntitiesQueryStoreAtDeletionTest.java index 7bf5fa3eb5..004f95d7cf 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/query/AssociationRevisionsOfEntitiesQueryStoreAtDeletionTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/query/AssociationRevisionsOfEntitiesQueryStoreAtDeletionTest.java @@ -18,7 +18,7 @@ import org.hibernate.testing.TestForIssue; @TestForIssue( jiraKey = "HHH-13817" ) public class AssociationRevisionsOfEntitiesQueryStoreAtDeletionTest extends AssociationRevisionsOfEntitiesQueryTest { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( EnversSettings.STORE_DATA_AT_DELETE, true ); } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/trackmodifiedentities/EntityNamesTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/trackmodifiedentities/EntityNamesTest.java index 37256646c9..e9fe03f889 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/trackmodifiedentities/EntityNamesTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/trackmodifiedentities/EntityNamesTest.java @@ -30,7 +30,7 @@ public class EntityNamesTest extends BaseEnversFunctionalTestCase { } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( EnversSettings.TRACK_ENTITIES_CHANGED_IN_REVISION, "true" ); diff --git a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java index eef14c3e04..bfa205a31e 100644 --- a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java +++ b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java @@ -49,9 +49,8 @@ public class HikariCPConnectionProvider implements ConnectionProvider, Configura // Configurable // ************************************************************************* - @SuppressWarnings("rawtypes") @Override - public void configure(Map props) throws HibernateException { + public void configure(Map props) throws HibernateException { try { LOGGER.debug( "Configuring HikariCP" ); @@ -91,8 +90,7 @@ public class HikariCPConnectionProvider implements ConnectionProvider, Configura } @Override - @SuppressWarnings("rawtypes") - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || HikariCPConnectionProvider.class.isAssignableFrom( unwrapType ) || DataSource.class.isAssignableFrom( unwrapType ); diff --git a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariConfigurationUtil.java b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariConfigurationUtil.java index 440ae3b8f6..b4d3b67fe9 100644 --- a/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariConfigurationUtil.java +++ b/hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariConfigurationUtil.java @@ -31,8 +31,7 @@ public class HikariConfigurationUtil { * @param props a map of Hibernate properties * @return a HikariConfig */ - @SuppressWarnings("rawtypes") - public static HikariConfig loadConfiguration(Map props) { + public static HikariConfig loadConfiguration(Map props) { Properties hikariProps = new Properties(); copyProperty( AvailableSettings.AUTOCOMMIT, props, "autoCommit", hikariProps ); @@ -43,11 +42,7 @@ public class HikariConfigurationUtil { copyIsolationSetting( props, hikariProps ); - for ( Object keyo : props.keySet() ) { - if ( !(keyo instanceof String) ) { - continue; - } - String key = (String) keyo; + for ( String key : props.keySet() ) { if ( key.startsWith( CONFIG_PREFIX ) ) { hikariProps.setProperty( key.substring( CONFIG_PREFIX.length() ), (String) props.get( key ) ); } @@ -56,14 +51,13 @@ public class HikariConfigurationUtil { return new HikariConfig( hikariProps ); } - @SuppressWarnings("rawtypes") - private static void copyProperty(String srcKey, Map src, String dstKey, Properties dst) { + private static void copyProperty(String srcKey, Map src, String dstKey, Properties dst) { if ( src.containsKey( srcKey ) ) { dst.setProperty( dstKey, (String) src.get( srcKey ) ); } } - private static void copyIsolationSetting(Map props, Properties hikariProps) { + private static void copyIsolationSetting(Map props, Properties hikariProps) { final Integer isolation = ConnectionProviderInitiator.extractIsolation( props ); if ( isolation != null ) { hikariProps.put( diff --git a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/JCacheRegionFactory.java b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/JCacheRegionFactory.java index 633a398f80..2eafcf0578 100644 --- a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/JCacheRegionFactory.java +++ b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/internal/JCacheRegionFactory.java @@ -183,7 +183,7 @@ public class JCacheRegionFactory extends RegionFactoryTemplate { } @Override - protected void prepareForUse(SessionFactoryOptions settings, Map configValues) { + protected void prepareForUse(SessionFactoryOptions settings, Map configValues) { this.cacheManager = resolveCacheManager( settings, configValues ); if ( this.cacheManager == null ) { throw new CacheException( "Could not locate/create CacheManager" ); @@ -193,7 +193,7 @@ public class JCacheRegionFactory extends RegionFactoryTemplate { ); } - protected CacheManager resolveCacheManager(SessionFactoryOptions settings, Map properties) { + protected CacheManager resolveCacheManager(SessionFactoryOptions settings, Map properties) { final Object explicitCacheManager = properties.get( ConfigSettings.CACHE_MANAGER ); if ( explicitCacheManager != null ) { return useExplicitCacheManager( settings, explicitCacheManager ); @@ -216,7 +216,7 @@ public class JCacheRegionFactory extends RegionFactoryTemplate { return cachingProvider.getDefaultClassLoader(); } - protected URI getUri(SessionFactoryOptions settings, Map properties) { + protected URI getUri(SessionFactoryOptions settings, Map properties) { String cacheManagerUri = getProp( properties, ConfigSettings.CONFIG_URI ); if ( cacheManagerUri == null ) { return null; @@ -238,11 +238,11 @@ public class JCacheRegionFactory extends RegionFactoryTemplate { } } - private String getProp(Map properties, String prop) { + private String getProp(Map properties, String prop) { return properties != null ? (String) properties.get( prop ) : null; } - protected CachingProvider getCachingProvider(final Map properties){ + protected CachingProvider getCachingProvider(final Map properties){ final CachingProvider cachingProvider; final String provider = getProp( properties, ConfigSettings.PROVIDER ); if ( provider != null ) { diff --git a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheClasspathConfigUriTest.java b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheClasspathConfigUriTest.java index 0ca43dc6c8..0b914c6289 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheClasspathConfigUriTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheClasspathConfigUriTest.java @@ -21,7 +21,7 @@ public class JCacheClasspathConfigUriTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( Environment.CACHE_REGION_FACTORY, "jcache" ); settings.put( ConfigSettings.CONFIG_URI, "classpath://hibernate-config/ehcache/jcache-ehcache-config.xml" ); } diff --git a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigRelativePathTest.java b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigRelativePathTest.java index d6882dde7c..7cac354535 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigRelativePathTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigRelativePathTest.java @@ -21,7 +21,7 @@ public class JCacheConfigRelativePathTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( Environment.CACHE_REGION_FACTORY, "jcache" ); settings.put( ConfigSettings.CONFIG_URI, "/hibernate-config/ehcache/jcache-ehcache-config.xml" ); } diff --git a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigUrlTest.java b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigUrlTest.java index f645a33f68..46d2841fa2 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigUrlTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheConfigUrlTest.java @@ -21,7 +21,7 @@ public class JCacheConfigUrlTest extends BaseNonConfigCoreFunctionalTestCase { @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( Environment.CACHE_REGION_FACTORY, "jcache" ); settings.put( ConfigSettings.CONFIG_URI, diff --git a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheTransactionalCacheConcurrencyStrategyTest.java b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheTransactionalCacheConcurrencyStrategyTest.java index 138841838b..39ee054199 100644 --- a/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheTransactionalCacheConcurrencyStrategyTest.java +++ b/hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/JCacheTransactionalCacheConcurrencyStrategyTest.java @@ -42,7 +42,7 @@ public class JCacheTransactionalCacheConcurrencyStrategyTest } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { settings.put( Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true" ); TestingJtaBootstrap.prepare( settings ); diff --git a/hibernate-micrometer/src/test/java/org/hibernate/test/stat/MicrometerCacheStatisticsTest.java b/hibernate-micrometer/src/test/java/org/hibernate/test/stat/MicrometerCacheStatisticsTest.java index df26a63f7d..0b32d78f94 100644 --- a/hibernate-micrometer/src/test/java/org/hibernate/test/stat/MicrometerCacheStatisticsTest.java +++ b/hibernate-micrometer/src/test/java/org/hibernate/test/stat/MicrometerCacheStatisticsTest.java @@ -64,7 +64,7 @@ public class MicrometerCacheStatisticsTest extends BaseNonConfigCoreFunctionalTe } @Override - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { super.addSettings( settings ); settings.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" ); settings.put( AvailableSettings.USE_QUERY_CACHE, "true" ); diff --git a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java index 2ffa8b9680..9fb42277d2 100644 --- a/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java +++ b/hibernate-proxool/src/main/java/org/hibernate/proxool/internal/ProxoolConnectionProvider.java @@ -83,7 +83,7 @@ public class ProxoolConnectionProvider } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || ProxoolConnectionProvider.class.isAssignableFrom( unwrapType ); } @@ -111,7 +111,7 @@ public class ProxoolConnectionProvider } @Override - public void configure(Map props) { + public void configure(Map props) { // Get the configurator files (if available) final String jaxpFile = (String) props.get( Environment.PROXOOL_XML ); final String propFile = (String) props.get( Environment.PROXOOL_PROPERTIES ); diff --git a/hibernate-proxool/src/test/java/org/hibernate/test/proxool/ProxoolTransactionIsolationConfigTest.java b/hibernate-proxool/src/test/java/org/hibernate/test/proxool/ProxoolTransactionIsolationConfigTest.java index 45b2f34f9a..6072cac095 100644 --- a/hibernate-proxool/src/test/java/org/hibernate/test/proxool/ProxoolTransactionIsolationConfigTest.java +++ b/hibernate-proxool/src/test/java/org/hibernate/test/proxool/ProxoolTransactionIsolationConfigTest.java @@ -6,6 +6,8 @@ */ package org.hibernate.test.proxool; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import org.hibernate.boot.registry.StandardServiceRegistry; @@ -22,14 +24,14 @@ import org.junit.Before; * @author Steve Ebersole */ public class ProxoolTransactionIsolationConfigTest extends BaseTransactionIsolationConfigTest { - private Properties properties; + private Map properties; private StandardServiceRegistry ssr; @Before public void setUp() { String poolName = "pool-one"; - properties = new Properties(); + properties = new HashMap<>(); properties.put( AvailableSettings.PROXOOL_POOL_ALIAS, poolName ); properties.put( AvailableSettings.PROXOOL_PROPERTIES, poolName + ".properties" ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java index 475f372e34..d917bfcfc2 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java @@ -7,10 +7,12 @@ package org.hibernate.testing; import java.util.Map; +import java.util.Properties; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Environment; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.ServiceRegistry; /** @@ -21,10 +23,16 @@ public final class ServiceRegistryBuilder { } public static StandardServiceRegistryImpl buildServiceRegistry() { - return buildServiceRegistry( Environment.getProperties() ); + return buildServiceRegistry( PropertiesHelper.map( Environment.getProperties() ) ); } - public static StandardServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) { + public static StandardServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) { + return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() + .applySettings( serviceRegistryConfig ) + .build(); + } + + public static StandardServiceRegistryImpl buildServiceRegistry(Properties serviceRegistryConfig) { return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings( serviceRegistryConfig ) .build(); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/boot/DialectFactoryTestingImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/boot/DialectFactoryTestingImpl.java index dcd23c54c5..44eab2ea7f 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/boot/DialectFactoryTestingImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/boot/DialectFactoryTestingImpl.java @@ -29,7 +29,7 @@ public class DialectFactoryTestingImpl implements DialectFactory { } @Override - public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) { + public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) { return dialect; } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/boot/ServiceRegistryTestingImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/boot/ServiceRegistryTestingImpl.java index 582ef06c06..2bdc43fe25 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/boot/ServiceRegistryTestingImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/boot/ServiceRegistryTestingImpl.java @@ -17,6 +17,7 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.dialect.spi.DialectFactory; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.StandardServiceInitiators; import org.hibernate.service.internal.ProvidedService; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -41,11 +42,11 @@ public class ServiceRegistryTestingImpl dialectFactoryService(), connectionProviderService() ), - Environment.getProperties() + PropertiesHelper.map( Environment.getProperties() ) ); } - public static ServiceRegistryTestingImpl forUnitTesting(Map settings) { + public static ServiceRegistryTestingImpl forUnitTesting(Map settings) { return new ServiceRegistryTestingImpl( true, new BootstrapServiceRegistryBuilder().build(), @@ -58,12 +59,12 @@ public class ServiceRegistryTestingImpl ); } - private static ProvidedService dialectFactoryService() { - return new ProvidedService( DialectFactory.class, new DialectFactoryTestingImpl() ); + private static ProvidedService dialectFactoryService() { + return new ProvidedService<>( DialectFactory.class, new DialectFactoryTestingImpl() ); } - private static ProvidedService connectionProviderService() { - return new ProvidedService( + private static ProvidedService connectionProviderService() { + return new ProvidedService<>( ConnectionProvider.class, ConnectionProviderBuilder.buildConnectionProvider( true ) ); @@ -72,9 +73,9 @@ public class ServiceRegistryTestingImpl public ServiceRegistryTestingImpl( boolean autoCloseRegistry, BootstrapServiceRegistry bootstrapServiceRegistry, - List serviceInitiators, - List providedServices, - Map configurationValues) { + List> serviceInitiators, + List> providedServices, + Map configurationValues) { super( autoCloseRegistry, bootstrapServiceRegistry, serviceInitiators, providedServices, configurationValues ); } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java b/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java index 224c523ea2..b2056d7115 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java @@ -50,7 +50,7 @@ public class CachingRegionFactory extends RegionFactoryTemplate { } @Override - protected void prepareForUse(SessionFactoryOptions settings, Map configValues) { + protected void prepareForUse(SessionFactoryOptions settings, Map configValues) { } @Override diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/common/connections/BaseTransactionIsolationConfigTest.java b/hibernate-testing/src/main/java/org/hibernate/testing/common/connections/BaseTransactionIsolationConfigTest.java index 7075a15910..3a40e3b643 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/common/connections/BaseTransactionIsolationConfigTest.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/common/connections/BaseTransactionIsolationConfigTest.java @@ -12,6 +12,7 @@ import java.util.Properties; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.service.spi.Configurable; import org.hibernate.service.spi.Startable; import org.hibernate.service.spi.Stoppable; @@ -39,9 +40,9 @@ public abstract class BaseTransactionIsolationConfigTest extends BaseUnitTestCas ConnectionProvider provider = getConnectionProviderUnderTest(); try { - ( (Configurable) provider ).configure( properties ); + ( (Configurable) provider ).configure( PropertiesHelper.map( properties ) ); - if ( Startable.class.isInstance( provider ) ) { + if ( provider instanceof Startable ) { ( (Startable) provider ).start(); } @@ -63,9 +64,9 @@ public abstract class BaseTransactionIsolationConfigTest extends BaseUnitTestCas ConnectionProvider provider = getConnectionProviderUnderTest(); try { - ( (Configurable) provider ).configure( properties ); + ( (Configurable) provider ).configure( PropertiesHelper.map( properties ) ); - if ( Startable.class.isInstance( provider ) ) { + if ( provider instanceof Startable ) { ( (Startable) provider ).start(); } @@ -87,9 +88,9 @@ public abstract class BaseTransactionIsolationConfigTest extends BaseUnitTestCas ConnectionProvider provider = getConnectionProviderUnderTest(); try { - ( (Configurable) provider ).configure( properties ); + ( (Configurable) provider ).configure( PropertiesHelper.map( properties ) ); - if ( Startable.class.isInstance( provider ) ) { + if ( provider instanceof Startable ) { ( (Startable) provider ).start(); } @@ -111,9 +112,9 @@ public abstract class BaseTransactionIsolationConfigTest extends BaseUnitTestCas ConnectionProvider provider = getConnectionProviderUnderTest(); try { - ( (Configurable) provider ).configure( properties ); + ( (Configurable) provider ).configure( PropertiesHelper.map( properties ) ); - if ( Startable.class.isInstance( provider ) ) { + if ( provider instanceof Startable ) { ( (Startable) provider ).start(); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java index abb5acd6ea..1ac81af6cf 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java @@ -19,6 +19,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.testing.DialectCheck; @@ -76,7 +77,7 @@ public class ConnectionProviderBuilder implements DialectCheck { public static DatasourceConnectionProviderImpl buildDataSourceConnectionProvider(String dbName) { try { - Class dataSourceClass = ReflectHelper.classForName( DATA_SOURCE, ConnectionProviderBuilder.class ); + Class dataSourceClass = ReflectHelper.classForName( DATA_SOURCE, ConnectionProviderBuilder.class ); DataSource actualDataSource = (DataSource) dataSourceClass.newInstance(); ReflectHelper.findSetterMethod( dataSourceClass, "URL", String.class ).invoke( actualDataSource, @@ -127,7 +128,7 @@ public class ConnectionProviderBuilder implements DialectCheck { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if ("getConnection".equals(method.getName())) { + if ( "getConnection".equals( method.getName() ) ) { if(actualConnection == null) { actualConnection = (Connection) method.invoke( target, args); connectionProxy = (Connection) Proxy.newProxyInstance( @@ -177,7 +178,7 @@ public class ConnectionProviderBuilder implements DialectCheck { return allowAggressiveRelease; } }; - connectionProvider.configure( props ); + connectionProvider.configure( PropertiesHelper.map( props ) ); return connectionProvider; } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/ConnectionProviderDelegate.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/ConnectionProviderDelegate.java index e1cd53ad46..2126878746 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/ConnectionProviderDelegate.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/ConnectionProviderDelegate.java @@ -64,10 +64,9 @@ public class ConnectionProviderDelegate implements } @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { if ( !configured ) { if ( connectionProvider == null ) { - @SuppressWarnings("unchecked") Map settings = new HashMap<>( configurationValues ); settings.remove( AvailableSettings.CONNECTION_PROVIDER ); connectionProvider = ConnectionProviderInitiator.INSTANCE.initiateService( @@ -105,7 +104,7 @@ public class ConnectionProviderDelegate implements } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return connectionProvider.isUnwrappableAs( unwrapType ); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/DataSourceStub.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/DataSourceStub.java index cb1866a3ad..7d35a8847e 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/DataSourceStub.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/DataSourceStub.java @@ -14,6 +14,7 @@ import javax.sql.DataSource; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.testing.env.ConnectionProviderBuilder; /** @@ -27,7 +28,7 @@ public class DataSourceStub implements DataSource { public DataSourceStub(String id) { this.id = id; connectionProvider = new DriverManagerConnectionProviderImpl(); - connectionProvider.configure( ConnectionProviderBuilder.getConnectionProviderProperties() ); + connectionProvider.configure( PropertiesHelper.map( ConnectionProviderBuilder.getConnectionProviderProperties() ) ); printWriter = null; } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInterceptor.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInterceptor.java index ddc96ece29..eecb5d6eef 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInterceptor.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInterceptor.java @@ -13,6 +13,7 @@ import org.hibernate.boot.SessionFactoryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.resource.jdbc.spi.StatementInspector; import static org.junit.Assert.assertEquals; @@ -34,7 +35,7 @@ public class SQLStatementInterceptor { } ); } - public SQLStatementInterceptor(Map settings) { + public SQLStatementInterceptor(Map settings) { settings.put( AvailableSettings.STATEMENT_INSPECTOR, (StatementInspector) sql -> { sqlQueries.add( sql ); return sql; @@ -52,7 +53,7 @@ public class SQLStatementInterceptor { } public SQLStatementInterceptor(Configuration configuration) { - this( configuration.getProperties() ); + this( PropertiesHelper.map( configuration.getProperties() ) ); } public LinkedList getSqlQueries() { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java index 43d03bbe5c..a5f320124a 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java @@ -34,7 +34,7 @@ public class SharedDriverManagerConnectionProviderImpl extends DriverManagerConn private Boolean supportsIsValid; @Override - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { final Config c = new Config( configurationValues ); if ( !c.isCompatible( config ) ) { if ( config != null ) { @@ -86,7 +86,7 @@ public class SharedDriverManagerConnectionProviderImpl extends DriverManagerConn private final Properties connectionProps; private final Integer isolation; - public Config(Map configurationValues) { + public Config(Map configurationValues) { this.autoCommit = ConfigurationHelper.getBoolean( AvailableSettings.AUTOCOMMIT, configurationValues, false ); this.minSize = ConfigurationHelper.getInt( MIN_SIZE, configurationValues, 2 ); this.maxSize = ConfigurationHelper.getInt( AvailableSettings.POOL_SIZE, configurationValues, 20 ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java index 407b2efaeb..e96882c134 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/JtaAwareConnectionProviderImpl.java @@ -9,6 +9,7 @@ package org.hibernate.testing.jta; import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; @@ -39,30 +40,27 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi private DriverManagerConnectionProviderImpl delegate; - private List nonEnlistedConnections = new ArrayList(); + private final List nonEnlistedConnections = new ArrayList<>(); @Override - public void configure(Map configurationValues) { - Properties connectionSettings = new Properties(); + public void configure(Map configurationValues) { + Map connectionSettings = new HashMap<>(); transferSetting( Environment.DRIVER, configurationValues, connectionSettings ); transferSetting( Environment.URL, configurationValues, connectionSettings ); transferSetting( Environment.USER, configurationValues, connectionSettings ); transferSetting( Environment.PASS, configurationValues, connectionSettings ); transferSetting( Environment.ISOLATION, configurationValues, connectionSettings ); Properties passThroughSettings = ConnectionProviderInitiator.getConnectionProperties( configurationValues ); - if ( passThroughSettings != null ) { - for ( String setting : passThroughSettings.stringPropertyNames() ) { - transferSetting( Environment.CONNECTION_PREFIX + '.' + setting, configurationValues, connectionSettings ); - } + for ( String setting : passThroughSettings.stringPropertyNames() ) { + transferSetting( Environment.CONNECTION_PREFIX + '.' + setting, configurationValues, connectionSettings ); } - connectionSettings.setProperty( Environment.AUTOCOMMIT, "false" ); + connectionSettings.put( Environment.AUTOCOMMIT, "false" ); delegate = new DriverManagerConnectionProviderImpl(); delegate.configure( connectionSettings ); } - @SuppressWarnings("unchecked") - private static void transferSetting(String settingName, Map source, Map target) { + private static void transferSetting(String settingName, Map source, Map target) { Object value = source.get( settingName ); if ( value != null ) { target.put( settingName, value ); @@ -122,10 +120,10 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi nonEnlistedConnections.remove( conn ); delegate.closeConnection( conn ); } - else { +// else { // do nothing. part of the enlistment contract here is that the XAResource wrapper // takes that responsibility. - } +// } } @Override @@ -143,7 +141,7 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return delegate.isUnwrappableAs( unwrapType ); } @@ -240,23 +238,23 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi } @Override - public int getTransactionTimeout() throws XAException { + public int getTransactionTimeout() { return transactionTimeout; } @Override - public boolean setTransactionTimeout(int i) throws XAException { + public boolean setTransactionTimeout(int i) { transactionTimeout = i; return true; } @Override - public boolean isSameRM(XAResource xaResource) throws XAException { - return xaResource != null && xaResource == this; + public boolean isSameRM(XAResource xaResource) { + return xaResource == this; } @Override - public Xid[] recover(int i) throws XAException { + public Xid[] recover(int i) { return new Xid[0]; } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaBootstrap.java b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaBootstrap.java index 50743b97e5..51d2934828 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaBootstrap.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jta/TestingJtaBootstrap.java @@ -17,8 +17,7 @@ import org.hibernate.cfg.AvailableSettings; public final class TestingJtaBootstrap { public static final TestingJtaBootstrap INSTANCE = new TestingJtaBootstrap(); - @SuppressWarnings("unchecked") - public static void prepare(Map configValues) { + public static void prepare(Map configValues) { configValues.put( AvailableSettings.JTA_PLATFORM, TestingJtaPlatformImpl.INSTANCE ); configValues.put( AvailableSettings.CONNECTION_PROVIDER, JtaAwareConnectionProviderImpl.class.getName() ); configValues.put( "javax.persistence.transactionType", "JTA" ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index 649c2b747d..609cb245b2 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -36,6 +36,7 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.build.AllowSysOut; +import org.hibernate.internal.util.PropertiesHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java index 3961a76f36..a6568e47a5 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java @@ -173,7 +173,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { final BootstrapServiceRegistry bsr = bsrb.build(); afterBootstrapServiceRegistryBuilt( bsr ); - final Map settings = new HashMap(); + final Map settings = new HashMap<>(); settings.put( GlobalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" ); settings.put( LocalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" ); if ( !Environment.getProperties().containsKey( Environment.CONNECTION_PROVIDER ) ) { @@ -191,7 +191,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { return ssrb; } - protected void addSettings(Map settings) { + protected void addSettings(Map settings) { } /** diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java index 78ba9a1a1d..ed14d690c7 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java @@ -239,8 +239,7 @@ public class EntityManagerFactoryExtension return; } - final HashMap settings = new HashMap<>( baseProperties ); - //noinspection unchecked + final HashMap settings = new HashMap<>( baseProperties ); settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP ); final StandardServiceRegistry serviceRegistry = model.getMetadataBuildingOptions().getServiceRegistry(); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ExtraAssertions.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ExtraAssertions.java index 161abce27b..b3be71f1c0 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ExtraAssertions.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ExtraAssertions.java @@ -65,13 +65,13 @@ public final class ExtraAssertions { return jdbcTypeCodeMap; } - private static Map generateJdbcTypeCache() { + private static Map generateJdbcTypeCache() { final Field[] fields = Types.class.getFields(); - Map cache = new HashMap( (int) ( fields.length * .75 ) + 1 ); + Map cache = new HashMap<>( (int) ( fields.length * .75 ) + 1 ); for ( Field field : fields ) { if ( Modifier.isStatic( field.getModifiers() ) ) { try { - cache.put( field.get( null ), field.getName() ); + cache.put( (Integer) field.get( null ), field.getName() ); } catch (Throwable ignore) { } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ServiceRegistryExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ServiceRegistryExtension.java index 630fa89b93..af64ea4594 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ServiceRegistryExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/ServiceRegistryExtension.java @@ -210,7 +210,7 @@ public class ServiceRegistryExtension } for ( ServiceRegistry.Service service : serviceRegistryAnn.services() ) { - ssrb.addService( service.role(), service.impl().newInstance() ); + ssrb.addService( (Class) service.role(), service.impl().newInstance() ); } } catch (Exception e) { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SessionFactoryExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SessionFactoryExtension.java index 5b945501e6..9f52b474e1 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SessionFactoryExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SessionFactoryExtension.java @@ -72,7 +72,7 @@ public class SessionFactoryExtension producer = (SessionFactoryProducer) testInstance; } else { - if ( !context.getElement().isPresent() ) { + if ( context.getElement().isEmpty() ) { throw new RuntimeException( "Unable to determine how to handle given ExtensionContext : " + context.getDisplayName() ); } @@ -154,8 +154,7 @@ public class SessionFactoryExtension return; } - final HashMap settings = new HashMap<>( baseProperties ); - //noinspection unchecked + final HashMap settings = new HashMap<>( baseProperties ); settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP ); if ( createSecondarySchemas ) { if ( !( model.getDatabase().getDialect().canCreateSchema() ) ) { @@ -373,7 +372,7 @@ public class SessionFactoryExtension public void inStatelessSession(Consumer action) { log.trace( "#inStatelessSession(Consumer)" ); - try (final StatelessSession statelessSession = getSessionFactory().openStatelessSession();) { + try ( final StatelessSession statelessSession = getSessionFactory().openStatelessSession() ) { log.trace( "StatelessSession opened, calling action" ); action.accept( statelessSession ); } @@ -386,7 +385,7 @@ public class SessionFactoryExtension public void inStatelessTransaction(Consumer action) { log.trace( "#inStatelessTransaction(Consumer)" ); - try (final StatelessSession statelessSession = getSessionFactory().openStatelessSession();) { + try ( final StatelessSession statelessSession = getSessionFactory().openStatelessSession() ) { log.trace( "StatelessSession opened, calling action" ); inStatelessTransaction( statelessSession, action ); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java b/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java index cf0e7eb142..252b86a10e 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/transaction/TransactionUtil.java @@ -643,7 +643,7 @@ public class TransactionUtil { * @param consumer {@link Statement} callback to execute statements in auto-commit mode * @param settings Settings to build a new {@link ServiceRegistry} */ - public static void doInAutoCommit(Consumer consumer, Map settings) { + public static void doInAutoCommit(Consumer consumer, Map settings) { StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder(); if ( settings != null ) { ssrb.applySettings( settings ); @@ -688,7 +688,7 @@ public class TransactionUtil { * @param settings Settings to build a new {@link ServiceRegistry} * @param statements statements to be executed in auto-commit mode */ - public static void doInAutoCommit(Map settings, String... statements) { + public static void doInAutoCommit(Map settings, String... statements) { doInAutoCommit( s -> { for ( String statement : statements ) { try { diff --git a/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/ViburDBCPConnectionProvider.java b/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/ViburDBCPConnectionProvider.java index 1668f8cf3d..55a8cda9c0 100644 --- a/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/ViburDBCPConnectionProvider.java +++ b/hibernate-vibur/src/main/java/org/hibernate/vibur/internal/ViburDBCPConnectionProvider.java @@ -51,8 +51,7 @@ public class ViburDBCPConnectionProvider implements ConnectionProvider, Configur private ViburDBCPDataSource dataSource = null; @Override - @SuppressWarnings("unchecked") - public void configure(Map configurationValues) { + public void configure(Map configurationValues) { dataSource = new ViburDBCPDataSource( transform( configurationValues ) ); dataSource.start(); } @@ -81,7 +80,7 @@ public class ViburDBCPConnectionProvider implements ConnectionProvider, Configur } @Override - public boolean isUnwrappableAs(Class unwrapType) { + public boolean isUnwrappableAs(Class unwrapType) { return ConnectionProvider.class.equals( unwrapType ) || ViburDBCPConnectionProvider.class.isAssignableFrom( unwrapType ); } @@ -97,41 +96,41 @@ public class ViburDBCPConnectionProvider implements ConnectionProvider, Configur } } - private static Properties transform(Map configurationValues) { + private static Properties transform(Map configurationValues) { Properties result = new Properties(); - String driverClassName = configurationValues.get( DRIVER ); + String driverClassName = (String) configurationValues.get( DRIVER ); if ( driverClassName != null ) { result.setProperty( "driverClassName", driverClassName ); } - String jdbcUrl = configurationValues.get( URL ); + String jdbcUrl = (String) configurationValues.get( URL ); if ( jdbcUrl != null ) { result.setProperty( "jdbcUrl", jdbcUrl ); } - String username = configurationValues.get( USER ); + String username = (String) configurationValues.get( USER ); if ( username != null ) { result.setProperty( "username", username ); } - String password = configurationValues.get( PASS ); + String password = (String) configurationValues.get( PASS ); if ( password != null ) { result.setProperty( "password", password ); } - String defaultTransactionIsolationValue = configurationValues.get( ISOLATION ); + String defaultTransactionIsolationValue = (String) configurationValues.get( ISOLATION ); if ( defaultTransactionIsolationValue != null ) { result.setProperty( "defaultTransactionIsolationValue", defaultTransactionIsolationValue ); } - String defaultAutoCommit = configurationValues.get( AUTOCOMMIT ); + String defaultAutoCommit = (String) configurationValues.get( AUTOCOMMIT ); if ( defaultAutoCommit != null ) { result.setProperty( "defaultAutoCommit", defaultAutoCommit ); } - for ( Map.Entry entry : configurationValues.entrySet() ) { + for ( Map.Entry entry : configurationValues.entrySet() ) { String key = entry.getKey(); if ( key.startsWith( VIBUR_PREFIX ) ) { key = key.substring( VIBUR_PREFIX.length() ); - result.setProperty( key, entry.getValue() ); + result.setProperty( key, (String) entry.getValue() ); } } diff --git a/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java b/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java index fc579b2bbf..6153c22d32 100644 --- a/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java +++ b/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java @@ -46,7 +46,8 @@ class ManagedProviderConnectionHelper implements ConnectionHelper { private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) { ConfigurationHelper.resolvePlaceHolders( properties ); - return (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings( properties ).build(); + return (StandardServiceRegistryImpl) + new StandardServiceRegistryBuilder().applySettings( properties ).build(); } public Connection getConnection() throws SQLException { diff --git a/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java b/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java index 25bc9089f7..c729246ba3 100644 --- a/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java +++ b/tooling/hibernate-ant/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java @@ -64,7 +64,6 @@ public class SchemaUpdate { execute( targetTypes, metadata, ( (MetadataImplementor) metadata ).getMetadataBuildingOptions().getServiceRegistry() ); } - @SuppressWarnings("unchecked") public void execute(EnumSet targetTypes, Metadata metadata, ServiceRegistry serviceRegistry) { if ( targetTypes.isEmpty() ) { LOG.debug( "Skipping SchemaExport as no targets were specified" ); @@ -74,7 +73,7 @@ public class SchemaUpdate { exceptions.clear(); LOG.runningHbm2ddlSchemaUpdate(); - Map config = new HashMap( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); + Map config = new HashMap<>( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); config.put( AvailableSettings.HBM2DDL_DELIMITER, delimiter ); config.put( AvailableSettings.FORMAT_SQL, format ); @@ -106,7 +105,7 @@ public class SchemaUpdate { * * @return A List containing the Exceptions occurred during the export */ - public List getExceptions() { + public List getExceptions() { return exceptions; } @@ -189,8 +188,7 @@ public class SchemaUpdate { return ssrBuilder.build(); } - private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, ServiceRegistry serviceRegistry) - throws Exception { + private static MetadataImplementor buildMetadata(CommandLineArgs parsedArgs, ServiceRegistry serviceRegistry) { final MetadataSources metadataSources = new MetadataSources( serviceRegistry ); for ( String filename : parsedArgs.hbmXmlFiles ) {