deniskuzZ commented on code in PR #5474:
URL: https://github.com/apache/hive/pull/5474#discussion_r1824305472


##########
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:
   warn would be misleading with that change when pmf is null
   ````
   LOG.warn("PersistenceManagerFactory returned null DataStoreCache object
   ````
   why don't we return it above finally when we check for null `pmf`? btw, can 
it even be null since in catch we do
   ````
   pmf = JDOHelper.getPersistenceManagerFactory(prop)
   ````
   that is supposed to throw JDOFatalUserException exception 



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

Reply via email to