kylin-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] shaofengshi closed pull request #319: KYLIN-3556, replace String.intern to avoid unexpected locking collisions
Date Tue, 30 Oct 2018 06:00:08 GMT
shaofengshi closed pull request #319: KYLIN-3556, replace String.intern to avoid unexpected
locking collisions
URL: https://github.com/apache/kylin/pull/319
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 c301d10035..54075ff850 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
@@ -35,7 +35,6 @@
 import java.util.NavigableSet;
 import java.util.TreeSet;
 
-import com.google.common.base.Preconditions;
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
@@ -47,6 +46,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Interner;
+import com.google.common.collect.Interners;
 import com.google.common.collect.Lists;
 
 public class JDBCResourceDAO {
@@ -72,6 +74,8 @@
 
     private FileSystem redirectFileSystem;
 
+    private Interner<String> interner = Interners.newStrongInterner();
+
     public JDBCResourceDAO(KylinConfig kylinConfig, String metadataIdentifier) throws SQLException
{
         this.kylinConfig = kylinConfig;
         this.connectionManager = JDBCConnectionManager.getConnectionManager();
@@ -162,7 +166,8 @@ public long getResourceTimestamp(final String resourcePath) throws SQLException
         return allResourceName;
     }
 
-    private void listResource(final String tableName, final String folderPath, final NavigableSet<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 {
@@ -280,7 +285,7 @@ public void putResource(final JDBCResource resource) throws SQLException
{
             @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) {
@@ -331,7 +336,7 @@ public void checkAndPutResource(final String resPath, final byte[] content,
fina
         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) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message