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


##########
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:
   yes, when reaching here the `pmf` shouldn't be null, the `finally` block 
will be executed whether there is a JDOFatalUserException or not, if in finally 
the `pmf` is null, there should be the exception thrown, adding the `return 
null` makes the impression this method can returning the nullable `pmf`, it 
makes little sense from my perspective.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to