LocalToken ensures object buffer is on heap Patch by Sam Tunnicliffe; reviewed by Alex Petrov for CASSANDRA-12651
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/820e7a8d Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/820e7a8d Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/820e7a8d Branch: refs/heads/trunk Commit: 820e7a8d810828d29f98a68dc35be33b40a5de62 Parents: 7dd609c Author: Sam Tunnicliffe <s...@beobal.com> Authored: Thu Nov 17 16:42:19 2016 +0000 Committer: Sam Tunnicliffe <s...@beobal.com> Committed: Tue Nov 29 16:56:37 2016 +0000 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/dht/LocalPartitioner.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/820e7a8d/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index a2c552e..b77d84a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.11 + * LocalToken ensures token values are cloned on heap (CASSANDRA-12651) * AnticompactionRequestSerializer serializedSize is incorrect (CASSANDRA-12934) * Prevent reloading of logback.xml from UDF sandbox (CASSANDRA-12535) Merged from 2.2: http://git-wip-us.apache.org/repos/asf/cassandra/blob/820e7a8d/src/java/org/apache/cassandra/dht/LocalPartitioner.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/dht/LocalPartitioner.java b/src/java/org/apache/cassandra/dht/LocalPartitioner.java index f9421c5..aaf2569 100644 --- a/src/java/org/apache/cassandra/dht/LocalPartitioner.java +++ b/src/java/org/apache/cassandra/dht/LocalPartitioner.java @@ -27,10 +27,11 @@ import org.apache.cassandra.db.CachedHashDecoratedKey; import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.ObjectSizes; +import org.apache.cassandra.utils.memory.HeapAllocator; public class LocalPartitioner implements IPartitioner { - private static final long EMPTY_SIZE = ObjectSizes.measure(new LocalPartitioner(null).new LocalToken(null)); + private static final long EMPTY_SIZE = ObjectSizes.measure(new LocalPartitioner(null).new LocalToken()); final AbstractType<?> comparator; // package-private to avoid access workarounds in embedded LocalToken. @@ -121,9 +122,14 @@ public class LocalPartitioner implements IPartitioner { static final long serialVersionUID = 8437543776403014875L; + private LocalToken() + { + super(null); + } + public LocalToken(ByteBuffer token) { - super(token); + super(HeapAllocator.instance.clone(token)); } @Override