fix NPE from circular dependency on compaction strategy

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/043d1808
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/043d1808
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/043d1808

Branch: refs/heads/cassandra-1.1
Commit: 043d1808366a40b81d5275090060b7372ae4cbf5
Parents: 853a759
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Sat May 26 00:22:00 2012 -0500
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Sat May 26 00:22:00 2012 -0500

----------------------------------------------------------------------
 .../org/apache/cassandra/db/ColumnFamilyStore.java |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/043d1808/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java 
b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 56de67e..b3da68e 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1730,7 +1730,10 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
             throw new RuntimeException("The min_compaction_threshold cannot be 
larger than the max.");
 
         this.minCompactionThreshold.set(minCompactionThreshold);
-        CompactionManager.instance.submitBackground(this);
+
+        // this is called as part of CompactionStrategy constructor; avoid 
circular dependency by checking for null
+        if (compactionStrategy != null)
+            CompactionManager.instance.submitBackground(this);
     }
 
     public int getMaximumCompactionThreshold()
@@ -1744,7 +1747,10 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
             throw new RuntimeException("The max_compaction_threshold cannot be 
smaller than the min.");
 
         this.maxCompactionThreshold.set(maxCompactionThreshold);
-        CompactionManager.instance.submitBackground(this);
+
+        // this is called as part of CompactionStrategy constructor; avoid 
circular dependency by checking for null
+        if (compactionStrategy != null)
+            CompactionManager.instance.submitBackground(this);
     }
 
     public boolean isCompactionDisabled()

Reply via email to