dengzhhu653 commented on code in PR #5474:
URL: https://github.com/apache/hive/pull/5474#discussion_r1825757406
##########
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:
I write a simple code,
```java
public static void main(String[] args) throws Exception {
String a = null;
try {
a();
} catch (SQLException e) {
throw new JDOFatalUserException();
} finally {
if (a == null) {
System.out.println("print a");
}
}
System.out.println("print b");
}
private static void a() throws Exception {
throw new JDOFatalUserException();
}
```
the output:
```
print a
Exception in thread "main" javax.jdo.JDOFatalUserException
at org.example.FinallyException.a(FinallyException.java:23)
at org.example.FinallyException.main(FinallyException.java:11)
```
as see, the finally is executed before the exception is thrown.
--
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]