spring Sping Boot Hikari Pool Threads -“Web应用程序似乎已启动名为[HikariPool-1管家]的线程,但无法停止它,

a64a0gku  于 2023-08-02  发布在  Spring
关注(0)|答案(1)|浏览(181)

(类似的问题here与Tomcat资源有关,而不是Sping Boot 托管bean)
两个Hikari DataSource池正在像这样创建:

@Primary
    @Bean(value="appDataSource",destroyMethod="close")
    @ConfigurationProperties("app.db.datasource")
    @Override
    public DataSource dataSource() {
        return DataSourceBuilder.create().build(); 
    }

@Bean(value="pacsDataSource",destroyMethod="close")
    @Override
    public DataSource dataSource() {
        return new HikariDataSource(hikariConfig());
    }

字符串
但是当应用程序关闭时,我在日志中看到以下错误,Java进程无法退出。从我所知道的,spring应该在这些数据源上调用close(),这应该终止池线程。

2023-04-24T11:02:24.758 [https-jsse-nio-8080-exec-2] WARN  org.apache.catalina.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
     java.base@15.0.1/jdk.internal.misc.Unsafe.park(Native Method)
     java.base@15.0.1/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
     java.base@15.0.1/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
     java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
     java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
     java.base@15.0.1/java.lang.Thread.run(Thread.java:832)

2023-04-24T11:02:24.759 [https-jsse-nio-8080-exec-2] WARN  org.apache.catalina.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [HikariPool-2 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@15.0.1/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@15.0.1/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
 java.base@15.0.1/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
 java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
 java.base@15.0.1/java.lang.Thread.run(Thread.java:832)


编辑:奇怪的是,我有一个虚拟机,这个错误并没有阻止java进程退出。所以我在努力找出区别。.jar完全相同,但存在其他环境差异。无论哪种方式,当spring Boot 关闭时,进程似乎都应该退出。

gt0wga4j

gt0wga4j1#

我有@Type注解,我删除了它,并得到了错误,然后我又把它放在错误解决。

@Type(type = "json")
    @Column(columnDefinition = "json", name = "payload")
    private Map<String, String> payload;

字符串

相关问题