cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/3] git commit: Fix rare potential NPE in HHOM page size calculation
Date Thu, 05 Jun 2014 22:00:25 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 60be74230 -> 029cd4031


Fix rare potential NPE in HHOM page size calculation

patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for
CASSANDRA-7354


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

Branch: refs/heads/cassandra-2.1
Commit: 1e49abaf9cbc0833146f30c32ab574cd892aa0a4
Parents: dc73f21
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Jun 5 18:50:04 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Jun 6 00:54:49 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                      |  1 +
 .../cassandra/db/HintedHandOffManager.java       | 19 +++++++++----------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1e49abaf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 40eee1b..a6ea188 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.17
+ * Fix rare potential NPE in HHOM page size calculation (CASSANDRA-7354)
  * Fix handling of empty counter replication mutations (CASSANDRA-7144)
  * Use LOCAL_ONE for non-superuser auth queries (CASSANDRA-7328)
  * Set keepalive on MessagingService connections (CASSANDRA-7170)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1e49abaf/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index a7a3e06..58702df 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -431,20 +431,19 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
         }
     }
 
+    // read less columns (mutations) per page if they are very large
     private int calculatePageSize()
     {
-        // read less columns (mutations) per page if they are very large
         int meanColumnCount = hintStore.getMeanColumns();
-        if (meanColumnCount > 0)
-        {
-            int averageColumnSize = (int) (hintStore.getMeanRowSize() / meanColumnCount);
-            // page size of 1 does not allow actual paging b/c of >= behavior on startColumn
-            return Math.max(2, Math.min(PAGE_SIZE, DatabaseDescriptor.getInMemoryCompactionLimit()
/ averageColumnSize));
-        }
-        else
-        {
+        if (meanColumnCount <= 0)
             return PAGE_SIZE;
-        }
+
+        int averageColumnSize = (int) (hintStore.getMeanRowSize() / meanColumnCount);
+        if (averageColumnSize <= 0)
+            return PAGE_SIZE;
+
+        // page size of 1 does not allow actual paging b/c of >= behavior on startColumn
+        return Math.max(2, Math.min(PAGE_SIZE, DatabaseDescriptor.getInMemoryCompactionLimit()
/ averageColumnSize));
     }
 
     /**


Mime
View raw message