[
https://issues.apache.org/jira/browse/KYLIN-3556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16668192#comment-16668192
]
ASF GitHub Bot commented on KYLIN-3556:
---------------------------------------
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:
[email protected]
> Interned string should not be used as lock object
> -------------------------------------------------
>
> Key: KYLIN-3556
> URL: https://issues.apache.org/jira/browse/KYLIN-3556
> Project: Kylin
> Issue Type: Bug
> Components: Metadata
> Affects Versions: v2.5.0
> Reporter: Ted Yu
> Assignee: Kaige Liu
> Priority: Minor
> Fix For: v2.5.1
>
>
> In JDBCResourceDAO :
> {code}
> public void execute(Connection connection) throws SQLException {
> synchronized (resPath.intern()) {
> {code}
> Locking on an interned string can cause unexpected locking collisions with
> other part of code.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)