This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
new bd1b84d in-jvm dtests should validate Instance#serializeMessage
serializeSize matches bytes written
bd1b84d is described below
commit bd1b84dc3b5667c969e6d0277eb40a8e475e149a
Author: David Capwell <[email protected]>
AuthorDate: Tue Sep 8 16:52:14 2020 -0700
in-jvm dtests should validate Instance#serializeMessage serializeSize
matches bytes written
patch by David Capwell; reviewed by Jon Meredith, Blake Eggleston for
CASSANDRA-16112
---
src/java/org/apache/cassandra/db/ReadCommand.java | 1 +
.../org/apache/cassandra/distributed/impl/Instance.java | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java
b/src/java/org/apache/cassandra/db/ReadCommand.java
index 81b6803..e135ebb 100644
--- a/src/java/org/apache/cassandra/db/ReadCommand.java
+++ b/src/java/org/apache/cassandra/db/ReadCommand.java
@@ -1256,6 +1256,7 @@ public abstract class ReadCommand implements ReadQuery
long size = 1; // message type (single byte)
size += TypeSizes.sizeof(command.isDigestQuery());
size += TypeSizes.sizeof(metadata.ksName);
+ size += TypeSizes.sizeof(metadata.cfName);
size += TypeSizes.sizeof((short) keySize) + keySize;
size += TypeSizes.sizeof((long) command.nowInSec());
diff --git
a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
index 95fefd2..f061779 100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
@@ -24,6 +24,7 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -287,7 +288,12 @@ public class Instance extends IsolatedExecutor implements
IInvokableInstance
long timestamp = System.currentTimeMillis();
out.writeInt((int) timestamp);
messageOut.serialize(out, version);
- return new MessageImpl(messageOut.verb.ordinal(),
out.toByteArray(), id, version, from);
+ byte[] bytes = out.toByteArray();
+ if (messageOut.serializedSize(version) + 12 != bytes.length)
+ throw new AssertionError(String.format("Message
serializedSize(%s) does not match what was written with serialize(out, %s) for
verb %s and serializer %s; " +
+ "expected %s, actual
%s", version, version, messageOut.verb, messageOut.serializer.getClass(),
+
messageOut.serializedSize(version) + 12, bytes.length));
+ return new MessageImpl(messageOut.verb.ordinal(), bytes, id,
version, from);
}
catch (IOException e)
{
@@ -429,7 +435,7 @@ public class Instance extends IsolatedExecutor implements
IInvokableInstance
}
catch (IOException e)
{
- throw new RuntimeException();
+ throw new RuntimeException(e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]