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:24:51 GMT
Repository: incubator-phoenix
Updated Branches:
  refs/heads/master 7d20af004 -> a71ced17a


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/a71ced17
Tree: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/tree/a71ced17
Diff: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/diff/a71ced17

Branch: refs/heads/master
Commit: a71ced17ab6c664fa191df0f977466b3c1b923a0
Parents: 7d20af0
Author: jamestaylor <jamestaylor@apache.org>
Authored: Tue Mar 18 13:13:33 2014 -0700
Committer: jamestaylor <jamestaylor@apache.org>
Committed: Tue Mar 18 13:22:11 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/a71ced17/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