deniskuzZ commented on code in PR #5474: URL: https://github.com/apache/hive/pull/5474#discussion_r1825982277
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java: ########## @@ -319,9 +327,17 @@ private static PersistenceManagerFactory initPMF(Configuration conf, boolean for LOG.warn("Could not create PersistenceManagerFactory using " + "connection pool properties, will fall back", e); pmf = JDOHelper.getPersistenceManagerFactory(prop); + } finally { + if (pmf == null && ds instanceof AutoCloseable) { + try (AutoCloseable close1 = (AutoCloseable) ds; + AutoCloseable close2 = (AutoCloseable) ds2 ) { + } catch (Exception e) { + LOG.warn("Failed to close the DataSource", e); + } + } } } - DataStoreCache dsc = pmf.getDataStoreCache(); + DataStoreCache dsc = pmf != null ? pmf.getDataStoreCache() : null; Review Comment: @dengzhhu653 that's because you catch SQLException, but throw JDOException ```` public static void main(String ... args) { String a = null; try { a(); } catch (Exception e) { System.out.println("catch block"); throw new JDOFatalUserException("outer"); } finally { System.out.println("finally"); if (a == null) { System.out.println("print a"); } } System.out.println("print b"); } private static void a() throws Exception { throw new JDOFatalUserException("inner"); } ```` catch block finally print a Exception in thread "main" javax.jdo.JDOFatalUserException: outer at org.apache.Main.main(Main.java:17) -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org