deniskuzZ commented on code in PR #5474:
URL: https://github.com/apache/hive/pull/5474#discussion_r1824295000
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java:
##########
@@ -302,23 +307,33 @@ private static PersistenceManagerFactory
initPMF(Configuration conf, boolean for
pmf = JDOHelper.getPersistenceManagerFactory(dsProp);
} else {
String sourceName = forCompactor ? "objectstore-compactor" :
"objectstore";
+ DataSource ds = null, ds2 = null;
try (DataSourceProvider.DataSourceNameConfigurator configurator =
new DataSourceProvider.DataSourceNameConfigurator(conf,
sourceName)) {
- DataSource ds = (maxPoolSize > 0) ? dsp.create(conf, maxPoolSize) :
dsp.create(conf);
+ ds = (maxPoolSize > 0) ? dsp.create(conf, maxPoolSize) :
dsp.create(conf);
// The secondary connection factory is used for schema generation, and
for value generation operations.
// We should use a different pool for the secondary connection factory
to avoid resource starvation.
// Since DataNucleus uses locks for schema generation and value
generation, 2 connections should be sufficient.
configurator.resetName("objectstore-secondary");
- DataSource ds2 = forCompactor ? ds : dsp.create(conf, /* maxPoolSize
*/ 2);
+ ds2 = forCompactor ? ds : dsp.create(conf, /* maxPoolSize */ 2);
dsProp.put(PropertyNames.PROPERTY_CONNECTION_FACTORY, ds);
dsProp.put(PropertyNames.PROPERTY_CONNECTION_FACTORY2, ds2);
+ databaseProduct = DatabaseProduct.determineDatabaseProduct(ds, conf);
dsProp.put(ConfVars.MANAGER_FACTORY_CLASS.getVarname(),
"org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
pmf = JDOHelper.getPersistenceManagerFactory(dsProp);
} catch (SQLException e) {
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;
Review Comment:
Nested blocks of code should not be left empty
[java:S108](https://sonarcloud.io/organizations/apache/rules?open=java%3AS108&rule_key=java%3AS108)
--
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]