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
commit 3a441f2e3d464265b15d6c1bf90e375f156dae7c Author: etherge <ethe...@163.com> AuthorDate: Mon Oct 29 17:39:44 2018 +0800 KYLIN-3556, replace String.intern to avoid unexpected locking collisions --- .../apache/kylin/common/persistence/JDBCResourceDAO.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 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 5ad484a..9a33716 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 @@ -30,6 +30,7 @@ import java.sql.SQLException; import java.sql.Types; import java.text.MessageFormat; import java.util.List; +import java.util.NavigableSet; import java.util.TreeSet; import org.apache.commons.io.IOUtils; @@ -43,6 +44,8 @@ import org.apache.kylin.common.util.HadoopUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.collect.Interner; +import com.google.common.collect.Interners; import com.google.common.collect.Lists; public class JDBCResourceDAO { @@ -69,6 +72,7 @@ public class JDBCResourceDAO { private FileSystem redirectFileSystem; public static final String LOG_TABLE_SUFFIX = "_log"; + private Interner<String> interner = Interners.newStrongInterner(); public JDBCResourceDAO(KylinConfig kylinConfig, String metadataIdentifier) throws SQLException { this.kylinConfig = kylinConfig; @@ -160,7 +164,8 @@ public class JDBCResourceDAO { return allResourceName; } - private void listResource(final String tableName, final String folderPath, final TreeSet<String> allResourceName, final boolean recursive) throws SQLException { + private void listResource(final String tableName, final String folderPath, + final NavigableSet<String> allResourceName, final boolean recursive) throws SQLException { executeSql(new SqlOperation() { @Override public void execute(Connection connection) throws SQLException { @@ -278,7 +283,7 @@ public class JDBCResourceDAO { @Override public void execute(Connection connection) throws SQLException { byte[] content = getResourceDataBytes(resource); - synchronized (resource.getPath().intern()) { + synchronized (interner.intern(resource.getPath())) { boolean existing = existResource(resource.getPath()); String tableName = getMetaTableName(resource.getPath()); if (existing) { @@ -329,7 +334,7 @@ public class JDBCResourceDAO { executeSql(new SqlOperation() { @Override public void execute(Connection connection) throws SQLException { - synchronized (resPath.intern()) { + synchronized (interner.intern(resPath)) { String tableName = getMetaTableName(resPath); if (!existResource(resPath)) { if (oldTS != 0) { @@ -460,8 +465,9 @@ 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(); + ResultSet rs = null; try { + rs = ps.executeQuery(); while (rs.next()) { if (tableName.equals(rs.getString(1))) { return true;