This is an automated email from the ASF dual-hosted git repository.
bdeggleston pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new b9c40e2573 Use seeded crc for PaxosBallotTracker checksum
b9c40e2573 is described below
commit b9c40e25738f0ca7fc38e51a026743ead3420ab7
Author: Blake Eggleston <[email protected]>
AuthorDate: Tue Aug 2 10:51:15 2022 -0700
Use seeded crc for PaxosBallotTracker checksum
Patch by Blake Eggleston; Reviewed by Benedict Elliot Smith for
CASSANDRA-17793
---
src/java/org/apache/cassandra/net/Crc.java | 2 +-
.../cassandra/service/paxos/uncommitted/PaxosBallotTracker.java | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/java/org/apache/cassandra/net/Crc.java
b/src/java/org/apache/cassandra/net/Crc.java
index 9cd6edd94f..8f63e51a93 100644
--- a/src/java/org/apache/cassandra/net/Crc.java
+++ b/src/java/org/apache/cassandra/net/Crc.java
@@ -45,7 +45,7 @@ public class Crc
}
}
- static CRC32 crc32()
+ public static CRC32 crc32()
{
CRC32 crc = crc32.get();
crc.reset();
diff --git
a/src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosBallotTracker.java
b/src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosBallotTracker.java
index 7404bffae4..41314a2eaf 100644
---
a/src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosBallotTracker.java
+++
b/src/java/org/apache/cassandra/service/paxos/uncommitted/PaxosBallotTracker.java
@@ -25,6 +25,7 @@ import java.util.zip.CRC32;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+
import org.apache.cassandra.service.ClientState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +38,7 @@ import org.apache.cassandra.service.paxos.Ballot;
import org.apache.cassandra.service.paxos.Commit;
import static
org.apache.cassandra.io.util.SequentialWriterOption.FINISH_ON_CLOSE;
+import static org.apache.cassandra.net.Crc.crc32;
/**
* Tracks the highest paxos ballot we've seen, and the lowest ballot we can
accept.
@@ -66,9 +68,6 @@ public class PaxosBallotTracker
this.lowBound = lowBound;
}
- /**
- * creates a new crc32 instance seeded with a non-zero value
- */
private static void serializeBallot(SequentialWriter writer, CRC32 crc,
Ballot ballot) throws IOException
{
ByteBuffer bytes = ballot.toBytes();
@@ -105,7 +104,7 @@ public class PaxosBallotTracker
throw new IOException("Unsupported ballot file version: " +
version);
byte[] bytes = new byte[16];
- CRC32 crc = new CRC32();
+ CRC32 crc = crc32();
Ballot highBallot = deserializeBallot(reader, crc, bytes);
Ballot lowBallot = deserializeBallot(reader, crc, bytes);
int checksum = Integer.reverseBytes(reader.readInt());
@@ -129,7 +128,7 @@ public class PaxosBallotTracker
try(SequentialWriter writer = new SequentialWriter(file,
FINISH_ON_CLOSE))
{
- CRC32 crc = new CRC32();
+ CRC32 crc = crc32();
writer.writeInt(FILE_VERSION);
serializeBallot(writer, crc, getHighBound());
serializeBallot(writer, crc, getLowBound());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]