Bug description
In JdbcChatMemoryRepositoryDialect
, the following method static JdbcChatMemoryRepositoryDialect from(DataSource dataSource)
makes this call String url = dataSource.getConnection().getMetaData().getURL().toLowerCase();
which connects to the datasource to grab the metadata and the datasource url to determine which type of repository dialect class to return. This connection is never closed.
Stack trace
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:127)
at org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepositoryDialect.from(JdbcChatMemoryRepositoryDialect.java:57)
Environment Java 21, Spring AI 1.0.0
Steps to reproduce Use the JdbcChatMemoryRepository to establish chat memory for an LLM.
Expected behavior
We should not have any datasource related connection leaks. dataSource.getConnection()
is AutoClosable and should probably just be wrapped in a try-with-resources