Skip to content

Commit 7569ccf

Browse files
committed
rename to CONNECTION_INFO_LOGGER
1 parent 8f453bd commit 7569ccf

File tree

10 files changed

+43
-34
lines changed

10 files changed

+43
-34
lines changed

hibernate-agroal/src/main/java/org/hibernate/agroal/internal/AgroalConnectionProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.getSchema;
4646
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasCatalog;
4747
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasSchema;
48+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
4849

4950
/**
5051
* {@link ConnectionProvider} based on Agroal connection pool.
@@ -105,7 +106,7 @@ private static <T> void copyProperty(Map<String, Object> properties, String key,
105106

106107
@Override
107108
public void configure(Map<String, Object> properties) throws HibernateException {
108-
ConnectionInfoLogger.INSTANCE.configureConnectionPool( "Agroal" );
109+
CONNECTION_INFO_LOGGER.configureConnectionPool( "Agroal" );
109110
try {
110111
final var config = toStringValuedProperties( properties );
111112
if ( !properties.containsKey( AgroalSettings.AGROAL_MAX_SIZE ) ) {
@@ -130,7 +131,7 @@ public void configure(Map<String, Object> properties) throws HibernateException
130131
agroalDataSource = AgroalDataSource.from( agroalProperties );
131132
}
132133
catch ( Exception e ) {
133-
ConnectionInfoLogger.INSTANCE.unableToInstantiateConnectionPool( e );
134+
CONNECTION_INFO_LOGGER.unableToInstantiateConnectionPool( e );
134135
throw new ConnectionProviderConfigurationException(
135136
"Could not configure Agroal: " + e.getMessage(), e );
136137
}
@@ -225,7 +226,7 @@ else if ( unwrapType.isAssignableFrom( AgroalDataSource.class ) ) {
225226
@Override
226227
public void stop() {
227228
if ( agroalDataSource != null ) {
228-
ConnectionInfoLogger.INSTANCE.cleaningUpConnectionPool(
229+
CONNECTION_INFO_LOGGER.cleaningUpConnectionPool(
229230
agroalDataSource.getConfiguration()
230231
.connectionPoolConfiguration()
231232
.connectionFactoryConfiguration()

hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.getSchema;
5252
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasCatalog;
5353
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasSchema;
54+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
5455
import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean;
5556
import static org.hibernate.internal.util.config.ConfigurationHelper.getInteger;
5657

@@ -135,7 +136,7 @@ else if ( unwrapType.isAssignableFrom( DataSource.class ) ) {
135136

136137
@Override
137138
public void configure(Map<String, Object> properties) {
138-
ConnectionInfoLogger.INSTANCE.configureConnectionPool( "c3p0" );
139+
CONNECTION_INFO_LOGGER.configureConnectionPool( "c3p0" );
139140

140141
final String jdbcDriverClass = extractSetting(
141142
properties,
@@ -205,15 +206,15 @@ private DataSource createDataSource(String jdbcUrl, Properties connectionProps,
205206
return pooledDataSource( unpooledDataSource( jdbcUrl, connectionProps ), poolProperties );
206207
}
207208
catch (Exception e) {
208-
ConnectionInfoLogger.INSTANCE.unableToInstantiateConnectionPool( e );
209+
CONNECTION_INFO_LOGGER.unableToInstantiateConnectionPool( e );
209210
throw new ConnectionProviderConfigurationException(
210211
"Could not configure c3p0: " + e.getMessage(), e );
211212
}
212213
}
213214

214215
private void loadDriverClass(String jdbcDriverClass) {
215216
if ( jdbcDriverClass == null ) {
216-
ConnectionInfoLogger.INSTANCE.jdbcDriverNotSpecified();
217+
CONNECTION_INFO_LOGGER.jdbcDriverNotSpecified();
217218
}
218219
else {
219220
try {
@@ -313,12 +314,12 @@ private void warnPropertyConflict(String hibernateStyle, String c3p0Style) {
313314

314315
@Override
315316
public void stop() {
316-
ConnectionInfoLogger.INSTANCE.cleaningUpConnectionPool( C3P0_CONFIG_PREFIX );
317+
CONNECTION_INFO_LOGGER.cleaningUpConnectionPool( C3P0_CONFIG_PREFIX );
317318
try {
318319
DataSources.destroy( dataSource );
319320
}
320321
catch (SQLException sqle) {
321-
ConnectionInfoLogger.INSTANCE.unableToDestroyConnectionPool( sqle );
322+
CONNECTION_INFO_LOGGER.unableToDestroyConnectionPool( sqle );
322323
}
323324
}
324325

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DataSourceConnectionProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import static org.hibernate.cfg.JdbcSettings.DATASOURCE;
2727
import static org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator.toIsolationNiceName;
28+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
2829

2930
/**
3031
* A {@link ConnectionProvider} that manages connections from an underlying {@link DataSource}.
@@ -110,11 +111,11 @@ else if ( dataSourceSetting instanceof String jndiName ) {
110111
}
111112

112113
if ( configuration.containsKey( JdbcSettings.AUTOCOMMIT ) ) {
113-
ConnectionInfoLogger.INSTANCE.ignoredSetting( JdbcSettings.AUTOCOMMIT,
114+
CONNECTION_INFO_LOGGER.ignoredSetting( JdbcSettings.AUTOCOMMIT,
114115
DataSourceConnectionProvider.class );
115116
}
116117
if ( configuration.containsKey( JdbcSettings.ISOLATION ) ) {
117-
ConnectionInfoLogger.INSTANCE.ignoredSetting( JdbcSettings.ISOLATION,
118+
CONNECTION_INFO_LOGGER.ignoredSetting( JdbcSettings.ISOLATION,
118119
DataSourceConnectionProvider.class );
119120
}
120121

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/DriverManagerConnectionProvider.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.getSchema;
4444
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasCatalog;
4545
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasSchema;
46+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
4647
import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean;
4748
import static org.hibernate.internal.util.config.ConfigurationHelper.getInt;
4849
import static org.hibernate.internal.util.config.ConfigurationHelper.getLong;
@@ -82,7 +83,7 @@ public void injectServices(ServiceRegistryImplementor serviceRegistry) {
8283

8384
@Override
8485
public void configure(Map<String, Object> configurationValues) {
85-
ConnectionInfoLogger.INSTANCE.usingHibernateBuiltInConnectionPool();
86+
CONNECTION_INFO_LOGGER.usingHibernateBuiltInConnectionPool();
8687
final PooledConnections pool = buildPool( configurationValues, serviceRegistry );
8788
final long validationInterval = getLong( VALIDATION_INTERVAL, configurationValues, 30 );
8889
state = new PoolState( pool, validationInterval );
@@ -181,7 +182,7 @@ private static Driver loadDriver(String driverClassName, ServiceRegistry service
181182
}
182183

183184
private static void logAvailableDrivers() {
184-
ConnectionInfoLogger.INSTANCE.jdbcDriverNotSpecified();
185+
CONNECTION_INFO_LOGGER.jdbcDriverNotSpecified();
185186
final var list = new StringBuilder();
186187
DriverManager.drivers()
187188
.forEach( driver -> {
@@ -190,7 +191,7 @@ private static void logAvailableDrivers() {
190191
}
191192
list.append( driver.getClass().getName() );
192193
} );
193-
ConnectionInfoLogger.INSTANCE.availableJdbcDrivers( list.toString() );
194+
CONNECTION_INFO_LOGGER.availableJdbcDrivers( list.toString() );
194195
}
195196

196197
private static String jdbcUrl(Map<String, Object> configuration) {
@@ -219,7 +220,7 @@ else if ( connectionCreatorFactory != null ) {
219220

220221
private static Driver loadDriverIfPossible(String driverClassName, ServiceRegistry serviceRegistry) {
221222
if ( driverClassName == null ) {
222-
ConnectionInfoLogger.INSTANCE.debug( "No driver class specified" );
223+
CONNECTION_INFO_LOGGER.debug( "No driver class specified" );
223224
return null;
224225
}
225226
else if ( serviceRegistry != null ) {
@@ -246,7 +247,7 @@ else if ( serviceRegistry != null ) {
246247
private static ConnectionCreatorFactory loadConnectionCreatorFactory(
247248
String connectionCreatorFactoryClassName, ServiceRegistry serviceRegistry) {
248249
if ( connectionCreatorFactoryClassName == null ) {
249-
ConnectionInfoLogger.INSTANCE.debug( "No connection creator factory class specified" );
250+
CONNECTION_INFO_LOGGER.debug( "No connection creator factory class specified" );
250251
return null;
251252
}
252253
else if ( serviceRegistry != null ) {
@@ -339,7 +340,7 @@ protected int getOpenConnections() {
339340
protected void validateConnectionsReturned() {
340341
final int allocationCount = getOpenConnections();
341342
if ( allocationCount != 0 ) {
342-
ConnectionInfoLogger.INSTANCE.error( "Connection leak detected: there are " + allocationCount + " unclosed connections");
343+
CONNECTION_INFO_LOGGER.error( "Connection leak detected: there are " + allocationCount + " unclosed connections");
343344
}
344345
}
345346

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/PoolState.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.concurrent.locks.ReentrantReadWriteLock;
1515

1616
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
17+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
1718

1819
class PoolState implements Runnable {
1920

@@ -76,7 +77,7 @@ void stop() {
7677
if ( !active ) {
7778
return;
7879
}
79-
ConnectionInfoLogger.INSTANCE.cleaningUpConnectionPool( pool.getUrl() );
80+
CONNECTION_INFO_LOGGER.cleaningUpConnectionPool( pool.getUrl() );
8081
active = false;
8182
if ( executorService != null ) {
8283
executorService.shutdown();
@@ -86,7 +87,7 @@ void stop() {
8687
pool.close();
8788
}
8889
catch (SQLException e) {
89-
ConnectionInfoLogger.INSTANCE.unableToDestroyConnectionPool( e );
90+
CONNECTION_INFO_LOGGER.unableToDestroyConnectionPool( e );
9091
}
9192
}
9293
finally {

hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/PooledConnections.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.sql.SQLException;
1212
import java.util.concurrent.ConcurrentLinkedQueue;
1313

14+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
15+
1416
class PooledConnections {
1517

1618
// Thanks to Oleg Varaksin and his article on object pooling using the {@link java.util.concurrent}
@@ -30,7 +32,7 @@ class PooledConnections {
3032

3133
private PooledConnections(
3234
Builder builder) {
33-
ConnectionInfoLogger.INSTANCE.debugf( "Initializing Connection pool with %s Connections", builder.initialSize );
35+
CONNECTION_INFO_LOGGER.debugf( "Initializing Connection pool with %s Connections", builder.initialSize );
3436
connectionCreator = builder.connectionCreator;
3537
connectionValidator = builder.connectionValidator == null
3638
? ConnectionValidator.ALWAYS_VALID
@@ -47,18 +49,18 @@ void validate() {
4749
if ( !primed && size >= minSize ) {
4850
// IMPL NOTE: the purpose of primed is to allow the pool to lazily reach its
4951
// defined min-size.
50-
ConnectionInfoLogger.INSTANCE.debug( "Connection pool now considered primed; min-size will be maintained" );
52+
CONNECTION_INFO_LOGGER.debug( "Connection pool now considered primed; min-size will be maintained" );
5153
primed = true;
5254
}
5355

5456
if ( size < minSize && primed ) {
5557
int numberToBeAdded = minSize - size;
56-
ConnectionInfoLogger.INSTANCE.debugf( "Adding %s Connections to the pool", numberToBeAdded );
58+
CONNECTION_INFO_LOGGER.debugf( "Adding %s Connections to the pool", numberToBeAdded );
5759
addConnections( numberToBeAdded );
5860
}
5961
else if ( size > maxSize ) {
6062
int numberToBeRemoved = size - maxSize;
61-
ConnectionInfoLogger.INSTANCE.debugf( "Removing %s Connections from the pool", numberToBeRemoved );
63+
CONNECTION_INFO_LOGGER.debugf( "Removing %s Connections from the pool", numberToBeRemoved );
6264
removeConnections( numberToBeRemoved );
6365
}
6466
}
@@ -83,7 +85,7 @@ private Connection releaseConnection(Connection conn) {
8385
t = ex;
8486
}
8587
closeConnection( conn, t );
86-
ConnectionInfoLogger.INSTANCE.debug( "Connection release failed. Closing pooled connection", t );
88+
CONNECTION_INFO_LOGGER.debug( "Connection release failed. Closing pooled connection", t );
8789
return null;
8890
}
8991

@@ -119,7 +121,7 @@ protected Connection prepareConnection(Connection conn) {
119121
t = ex;
120122
}
121123
closeConnection( conn, t );
122-
ConnectionInfoLogger.INSTANCE.debug( "Connection preparation failed. Closing pooled connection", t );
124+
CONNECTION_INFO_LOGGER.debug( "Connection preparation failed. Closing pooled connection", t );
123125
return null;
124126
}
125127

@@ -128,14 +130,14 @@ protected void closeConnection(Connection conn, Throwable t) {
128130
conn.close();
129131
}
130132
catch (SQLException ex) {
131-
ConnectionInfoLogger.INSTANCE.unableToClosePooledConnection( ex );
133+
CONNECTION_INFO_LOGGER.unableToClosePooledConnection( ex );
132134
if ( t != null ) {
133135
t.addSuppressed( ex );
134136
}
135137
}
136138
finally {
137139
if ( !allConnections.remove( conn ) ) {
138-
ConnectionInfoLogger.INSTANCE.debug( "Connection remove failed." );
140+
CONNECTION_INFO_LOGGER.debug( "Connection remove failed." );
139141
}
140142
}
141143
}
@@ -144,7 +146,7 @@ public void close() throws SQLException {
144146
try {
145147
final int allocationCount = allConnections.size() - availableConnections.size();
146148
if ( allocationCount > 0 ) {
147-
ConnectionInfoLogger.INSTANCE.error(
149+
CONNECTION_INFO_LOGGER.error(
148150
"Connection leak detected: there are " + allocationCount + " unclosed connections upon shutting down pool " + getUrl() );
149151
}
150152
}

hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import static org.hibernate.cfg.JdbcSettings.JAKARTA_HBM2DDL_DB_VERSION;
6666
import static org.hibernate.engine.config.spi.StandardConverters.BOOLEAN;
6767
import static org.hibernate.context.spi.MultiTenancy.isMultiTenancyEnabled;
68+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
6869
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
6970
import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues;
7071
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
@@ -173,7 +174,7 @@ else if ( explicitDialectConfiguration( explicitDatabaseName, configurationValue
173174
// For Hibernate Reactive: it needs to disable or customize the log
174175
protected void logConnectionInfo(DatabaseConnectionInfo databaseConnectionInfo) {
175176
// Standardized info logging
176-
ConnectionInfoLogger.INSTANCE.logConnectionInfoDetails( databaseConnectionInfo.toInfoString() );
177+
CONNECTION_INFO_LOGGER.logConnectionInfoDetails( databaseConnectionInfo.toInfoString() );
177178
}
178179

179180
private DatabaseConnectionInfo buildInfo(ServiceRegistryImplementor registry, JdbcEnvironment environment) {

hibernate-core/src/main/java/org/hibernate/internal/log/ConnectionInfoLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface ConnectionInfoLogger extends BasicLogger {
3737
/**
3838
* Static access to the logging instance
3939
*/
40-
ConnectionInfoLogger INSTANCE = Logger.getMessageLogger( MethodHandles.lookup(), ConnectionInfoLogger.class, LOGGER_NAME );
40+
ConnectionInfoLogger CONNECTION_INFO_LOGGER = Logger.getMessageLogger( MethodHandles.lookup(), ConnectionInfoLogger.class, LOGGER_NAME );
4141

4242
@LogMessage(level = WARN)
4343
@Message(value = "Using built-in connection pool (not intended for production use)", id = 10001002)

hibernate-core/src/test/java/org/hibernate/orm/test/datasource/DataSourceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public class DataSourceTest {
3333
@Test
3434
void test(EntityManagerFactoryScope scope) {
3535
Listener listener = new Listener();
36-
LogInspectionHelper.registerListener( listener, ConnectionInfoLogger.INSTANCE );
36+
LogInspectionHelper.registerListener( listener, ConnectionInfoLogger.CONNECTION_INFO_LOGGER );
3737
scope.getEntityManagerFactory();
38-
LogInspectionHelper.clearAllListeners( ConnectionInfoLogger.INSTANCE );
38+
LogInspectionHelper.clearAllListeners( ConnectionInfoLogger.CONNECTION_INFO_LOGGER );
3939
Dialect dialect = scope.getDialect();
4040
assertTrue( dialect instanceof OracleDialect
4141
|| dialect instanceof DB2Dialect

hibernate-hikaricp/src/main/java/org/hibernate/hikaricp/internal/HikariCPConnectionProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasCatalog;
3434
import static org.hibernate.engine.jdbc.connections.internal.DatabaseConnectionInfoImpl.hasSchema;
3535
import static org.hibernate.hikaricp.internal.HikariConfigurationUtil.loadConfiguration;
36+
import static org.hibernate.internal.log.ConnectionInfoLogger.CONNECTION_INFO_LOGGER;
3637
import static org.hibernate.internal.util.StringHelper.isBlank;
3738

3839
/**
@@ -67,12 +68,12 @@ public class HikariCPConnectionProvider implements ConnectionProvider, Configura
6768
@Override
6869
public void configure(Map<String, Object> configuration) throws HibernateException {
6970
try {
70-
ConnectionInfoLogger.INSTANCE.configureConnectionPool( "HikariCP" );
71+
CONNECTION_INFO_LOGGER.configureConnectionPool( "HikariCP" );
7172
hikariConfig = loadConfiguration( configuration );
7273
hikariDataSource = new HikariDataSource( hikariConfig );
7374
}
7475
catch (Exception e) {
75-
ConnectionInfoLogger.INSTANCE.unableToInstantiateConnectionPool( e );
76+
CONNECTION_INFO_LOGGER.unableToInstantiateConnectionPool( e );
7677
throw new ConnectionProviderConfigurationException(
7778
"Could not configure HikariCP: " + e.getMessage(), e );
7879
}
@@ -168,7 +169,7 @@ else if ( unwrapType.isAssignableFrom( HikariConfig.class ) ) {
168169
@Override
169170
public void stop() {
170171
if ( hikariDataSource != null ) {
171-
ConnectionInfoLogger.INSTANCE.cleaningUpConnectionPool( "HikariCP" );
172+
CONNECTION_INFO_LOGGER.cleaningUpConnectionPool( "HikariCP" );
172173
hikariDataSource.close();
173174
}
174175
}

0 commit comments

Comments
 (0)