use logger with level arg

This commit is contained in:
Jörg Prante 2024-03-19 18:10:06 +01:00
parent 8a92b3f45c
commit c2b05476f2
3 changed files with 18 additions and 11 deletions

View file

@ -149,8 +149,10 @@ public class Pool implements BagStateListener {
int maxPoolSize = config.getMaximumPoolSize();
LinkedBlockingQueue<Runnable> addConnectionQueue = new LinkedBlockingQueue<>(maxPoolSize);
this.addConnectionQueueReadOnlyView = Collections.unmodifiableCollection(addConnectionQueue);
this.addConnectionExecutor = createThreadPoolExecutor(addConnectionQueue, poolName + " connection adder", threadFactory, new ThreadPoolExecutor.DiscardOldestPolicy());
this.closeConnectionExecutor = createThreadPoolExecutor(maxPoolSize, poolName + " connection closer", threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
this.addConnectionExecutor = createThreadPoolExecutor(addConnectionQueue,
poolName + " connection adder", threadFactory, new ThreadPoolExecutor.DiscardOldestPolicy());
this.closeConnectionExecutor = createThreadPoolExecutor(maxPoolSize,
poolName + " connection closer", threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
this.leakTaskFactory = new ProxyLeakTaskFactory(config.getLeakDetectionThreshold(), houseKeepingExecutorService);
this.houseKeeperTask = houseKeepingExecutorService.scheduleWithFixedDelay(new HouseKeeper(this), 100L, config.getHousekeepingPeriodMs(), TimeUnit.MILLISECONDS);
if (Boolean.getBoolean("org.xbib.jdbc.connection.pool.blockUntilFilled") && config.getInitializationFailTimeout() > 1) {

View file

@ -29,12 +29,17 @@ public class DriverDataSource implements DataSource {
private Driver driver;
public DriverDataSource(String jdbcUrl, String driverClassName, Properties properties, String username, String password) {
public DriverDataSource(String jdbcUrl,
String driverClassName,
Properties properties,
String username,
String password) {
this.jdbcUrl = jdbcUrl;
this.driverProperties = new Properties();
for (Entry<Object, Object> entry : properties.entrySet()) {
driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString());
}
logger.log(Level.INFO, "DriverManager looking for JDBC URL " + jdbcUrl);
if (username != null) {
setUser(username);
}
@ -51,25 +56,25 @@ public class DriverDataSource implements DataSource {
}
}
if (driver == null) {
logger.warning("Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
logger.log(Level.WARNING, "Registered driver with driverClassName was not found, trying direct instantiation: " + driverClassName);
Class<?> driverClass = null;
ClassLoader threadContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
if (threadContextClassLoader != null) {
try {
driverClass = threadContextClassLoader.loadClass(driverClassName);
logger.fine("Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
logger.log(Level.FINE, "Driver class found in Thread context class loader: " + driverClassName + " " + threadContextClassLoader);
} catch (ClassNotFoundException e) {
logger.fine("Driver class not found in Thread context class loader, trying classloader: " +
logger.log(Level.FINE, "Driver class not found in Thread context class loader, trying classloader: " +
driverClassName + " " + threadContextClassLoader + " " + this.getClass().getClassLoader());
}
}
if (driverClass == null) {
driverClass = this.getClass().getClassLoader().loadClass(driverClassName);
logger.fine("Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
logger.log(Level.FINE, "Driver class found in the PoolConfig class classloader:" + driverClassName + " " + this.getClass().getClassLoader());
}
} catch (ClassNotFoundException e) {
logger.fine("Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
logger.log(Level.FINE, "Failed to load driver class from PoolConfig class classloader: " + driverClassName + " " + this.getClass().getClassLoader());
}
if (driverClass != null) {
try {
@ -84,7 +89,7 @@ public class DriverDataSource implements DataSource {
try {
if (driver == null) {
driver = DriverManager.getDriver(jdbcUrl);
logger.fine("Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
logger.log(Level.FINE, "Loaded driver with class name for jdbcUrl " + driver.getClass().getName() + " " + sanitizedUrl);
} else if (!driver.acceptsURL(jdbcUrl)) {
throw new RuntimeException("Driver " + driverClassName + " claims to not accept jdbcUrl " + sanitizedUrl);
}

View file

@ -102,7 +102,7 @@ public class DatabaseImpl implements Database {
@Override
public void commitNow() {
if (options.ignoreTransactionControl()) {
logger.fine("Ignoring call to commitNow()");
logger.log(Level.FINE, "Ignoring call to commitNow()");
return;
}
if (!options.allowTransactionControl()) {
@ -118,7 +118,7 @@ public class DatabaseImpl implements Database {
@Override
public void rollbackNow() {
if (options.ignoreTransactionControl()) {
logger.fine("Ignoring call to rollbackNow()");
logger.log(Level.FINE, "Ignoring call to rollbackNow()");
return;
}
if (!options.allowTransactionControl()) {