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


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java:
##########
@@ -129,8 +129,21 @@ protected Connection getConnection() {
     throw new RuntimeException("unexpected type for connection handle");
   }
 
+  protected boolean isOpen() {
+    if (handle == null) {
+      return false;
+    }
+    try {
+      if (handle instanceof Connection)
+        return ((Connection) handle).isValid(3);
+    } catch (SQLException e) {
+      LOG.warn("Could not validate jdbc connection to "+ jdbcUrl, e);
+    }
+    return false;
+  }
+
   @Override public void close() {
-    if (isOpen) {
+    if (isOpen()) {

Review Comment:
   Sorry, what I mean is that we can use `Connection#isClosed` to close the 
connection, the `isOpen()` method can remain the same(check by 
`Connection.isValid`), we'd better not to close the connection in this method.
   



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