This is an automated email from the ASF dual-hosted git repository. shaofengshi pushed a commit to branch 2.5.x in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/2.5.x by this push: new 0c43dc7 KYLIN-3557 PreparedStatement not closed in JDBCResourceDAO 0c43dc7 is described below commit 0c43dc7133f065cf685e6284f6b5af77fe2cd619 Author: shaofengshi <shaofeng...@apache.org> AuthorDate: Wed Sep 12 09:59:36 2018 +0800 KYLIN-3557 PreparedStatement not closed in JDBCResourceDAO --- .../org/apache/kylin/common/persistence/JDBCResourceDAO.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java index ed2088e..3cd192e 100644 --- a/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java +++ b/core-common/src/main/java/org/apache/kylin/common/persistence/JDBCResourceDAO.java @@ -38,6 +38,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.Path; import org.apache.kylin.common.KylinConfig; +import org.apache.kylin.common.util.DBUtils; import org.apache.kylin.common.util.HadoopUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -439,10 +440,15 @@ public class JDBCResourceDAO { private boolean checkTableExists(final String tableName, final Connection connection) throws SQLException { final PreparedStatement ps = connection.prepareStatement(getCheckTableExistsSql(tableName)); final ResultSet rs = ps.executeQuery(); - while (rs.next()) { - if (tableName.equals(rs.getString(1))) { - return true; + try { + while (rs.next()) { + if (tableName.equals(rs.getString(1))) { + return true; + } } + } finally { + DBUtils.closeQuietly(rs); + DBUtils.closeQuietly(ps); } return false;