phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject git commit: PHOENIX-872 getConnection() sometimes fails with a ConcurrentModificationException (JamesTaylor)
Date Tue, 18 Mar 2014 20:14:49 GMT
Repository: incubator-phoenix
Updated Branches:
  refs/heads/3.0 44a6f518d -> 838f56f4c


PHOENIX-872 getConnection() sometimes fails with a ConcurrentModificationException (JamesTaylor)


Project: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/commit/838f56f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/tree/838f56f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/diff/838f56f4

Branch: refs/heads/3.0
Commit: 838f56f4cfacc93b4f1f086e2e9250b4a536691f
Parents: 44a6f51
Author: jamestaylor <jamestaylor@apache.org>
Authored: Tue Mar 18 13:13:33 2014 -0700
Committer: jamestaylor <jamestaylor@apache.org>
Committed: Tue Mar 18 13:13:33 2014 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/schema/PMetaDataImpl.java  | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/838f56f4/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
index a1f7431..87df307 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
@@ -231,17 +231,19 @@ public class PMetaDataImpl implements PMetaData {
 
     @Override
     public PMetaData pruneTables(Pruner pruner) {
+        List<PTableKey> keysToPrune = Lists.newArrayListWithExpectedSize(this.getTables().size());
         for (PTable table : this.getTables()) {
             if (pruner.prune(table)) {
-                Cache newCache = this.getTables().clone();
-                for (PTable value : this.getTables()) { // Go through old to prevent concurrent
modification exception
-                    if (pruner.prune(value)) {
-                        newCache.remove(value.getKey());
-                    }
-                }
-                return new PMetaDataImpl(newCache);
+                keysToPrune.add(table.getKey());
             }
         }
-        return this;
+        if (keysToPrune.isEmpty()) {
+            return this;
+        }
+        Cache tables = metaData.clone();
+        for (PTableKey key : keysToPrune) {
+            tables.remove(key);
+        }
+        return new PMetaDataImpl(tables);
     }
 }


Mime
View raw message