justinmclean commented on code in PR #8210:
URL: https://github.com/apache/gravitino/pull/8210#discussion_r2287356543


##########
core/src/main/java/org/apache/gravitino/storage/relational/session/SqlSessions.java:
##########
@@ -111,4 +89,19 @@ public static void closeSqlSession() {
   public static <T> T getMapper(Class<T> className) {
     return getSqlSession().getMapper(className);
   }
+
+  private static void executeAndCleanupSession(Consumer<SqlSession> consumer) {
+    SqlSession sqlSession = sessions.get();
+
+    if (sqlSession == null) {
+      getSessions().remove();
+      return;
+    }
+
+    try (sqlSession) {
+      consumer.accept(sqlSession);
+    } finally {
+      sessions.remove();
+    }
+  }
 }

Review Comment:
   This is missing the call to sqlSession.close() Also, note you'll need to do 
more than just add it, as a consumer.accept(sqlSession) could throw an 
exception, causing the sqlSession.close() call to be skipped.



-- 
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]

Reply via email to