LuciferYang commented on code in PR #13450:
URL: https://github.com/apache/gravitino/pull/13450#discussion_r4081844145
##########
core/src/test/java/org/apache/gravitino/stats/storage/TestJdbcPartitionStatisticStorage.java:
##########
@@ -101,6 +102,21 @@ public void setUp() throws Exception {
storage = new JdbcPartitionStatisticStorage(mockDataSource);
}
+ @Test
+ public void testCloseClosesOwnedDataSource() throws Exception {
+ // The storage is the only reachable owner of the pooled DataSource (the
+ // factory is discarded by the manager), so close() must release it.
+ BasicDataSource dataSource = new BasicDataSource();
+ dataSource.setDriverClassName("org.h2.Driver");
+ dataSource.setUrl("jdbc:h2:mem:stats_close_test;DB_CLOSE_DELAY=-1");
+
+ try (JdbcPartitionStatisticStorage owned = new
JdbcPartitionStatisticStorage(dataSource)) {
+ // no-op: never open a connection
+ }
+
+ assertTrue(dataSource.isClosed());
+ }
Review Comment:
Done. `testCloseClosesOwnedDataSource` now calls `close()` a second time and
asserts it does not throw and the pool stays closed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]