Hikari连接泄漏错误

时间:2016-09-15 09:23:53

标签: java sql-server-2008 sqldatasource hikaricp

我已经用java配置实现了Hikari连接,代码如下,

HikariConfig sqlConfig = new HikariConfig();
sqlConfig.setDataSourceClassName(WebAppListener.getContextParameter(DB_DRIVER_STRING));
                sqlConfig.addDataSourceProperty("url", WebAppListener.getContextParameter(DB_CONNECTION_STRING));
                sqlConfig.addDataSourceProperty("user", WebAppListener.getContextParameter(DB_USER_NAME));
                sqlConfig.addDataSourceProperty("password", WebAppListener.getContextParameter(DB_PASSWORD));
                sqlConfig.setLeakDetectionThreshold(TimeUnit.SECONDS.toMillis(30));
                sqlConfig.setValidationTimeout(TimeUnit.MINUTES.toMillis(1)); 
                sqlConfig.setMaximumPoolSize(POOL_SIZE);
                sqlConfig.setMinimumIdle(0);
                sqlConfig.setMaxLifetime(TimeUnit.MINUTES.toMillis(2)); // 120 seconds

                sqlConfig.setIdleTimeout(TimeUnit.MINUTES.toMillis(1)); // minutes
                sqlConfig.setConnectionTimeout(TimeUnit.MINUTES.toMillis(5));
                sqlConfig.setPoolName(POOL_NAME);
                sqlConfig.setAutoCommit(true);
                sqlConfig.setInitializationFailFast(false);

                dataSource = new HikariDataSource(sqlConfig);

                sqlConfig.setConnectionTestQuery("/* ping */ SELECT 1");
                if (null != connection) {
                    log.info("webAppListener.java :Hikari ::NEW Connection successful! : " + connection.hashCode());
                }
                else {
                    connection = dataSource.getConnection();
                }

但是当我部署我的应用程序时,它会提供这种日志:

15-Sep-2016 13:34:28.553 WARNING [http-nio-8084-exec-1658] org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads The web application [/HIKARI_PROJ] appears to have started a thread named [HikariConnPool housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 java.lang.Thread.run(Thread.java:745)

我的应用程序在开发服务器上没有任何中断的情况下运行,请帮助我,我在互联网上搜索但我没有得到任何解决方案。

0 个答案:

没有答案