GORM 没有关闭 grails 控制之外的连接 类

GORM not closing connection outside of grails controlled classes

我在grails 2.4.3上有一个方法(我去掉了无关紧要的部分):

@Override
protected void handleAnswerEvent(Message event) {
     def con = Contrato.find("from Contrato where ? in elements(telefones)", [tel])
}

但是这个方法 运行 在 grails 管理之外的一个线程中 类 (我不太确定我在这里说的是否有意义...)。关键是过了一会儿它给了我:

org.apache.tomcat.jdbc.pool.PoolExhaustedException: [http-bio-8080-exec-254] Timeout: Pool empty.

更改最大连接数并不能解决泄漏问题。我应该对 grails 做些什么来自动关闭它,或者有其他方法可以解决这个问题吗?

看看这些链接,我想它们可能会帮助您解决问题

https://jira.grails.org/browse/GRAILS-11043

https://jira.grails.org/browse/GRAILS-11700

谢谢。

[更新]

问题与连接池泄漏问题有关。如果您没有显式关闭连接,则在事务上下文之外使用 GroovySQL 会泄漏连接(GRAILS-5454 修复了事务上下文中的问题,但问题仍然存在于事务之外)。 看看这些链接,我想它们可能会帮助您解决问题。问题已在 grails 2.4.4

中得到解决

https://github.com/grails/grails-core/issues/2797

https://github.com/grails/grails-core/issues/3017

https://github.com/grails/grails-core/issues/2776

谢谢。