You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/06/04 17:21:30 UTC
[1/3] cassandra git commit: Fix error response to unsupported
protocol version
Repository: cassandra
Updated Branches:
refs/heads/trunk 94ff7a5eb -> 1a14efdfd
Fix error response to unsupported protocol version
Patch by Tyler Hobbs; reviewed by Stefania Alborghetti for
CASSANDRA-9451
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b3177f15
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b3177f15
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b3177f15
Branch: refs/heads/trunk
Commit: b3177f15aed1d60ec3cc6166133102f86a795844
Parents: be3e389
Author: Tyler Hobbs <ty...@apache.org>
Authored: Thu Jun 4 10:16:19 2015 -0500
Committer: Tyler Hobbs <ty...@apache.org>
Committed: Thu Jun 4 10:16:19 2015 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../org/apache/cassandra/transport/Frame.java | 4 ++-
.../transport/messages/ErrorMessage.java | 13 +++++++--
.../cassandra/transport/ProtocolErrorTest.java | 30 ++++++++++++++++++++
4 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3177f15/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f5f9862..eea1640 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
2.1.6
+ * Use ProtocolError code instead of ServerError code for native protocol
+ error responses to unsupported protocol versions (CASSANDRA-9451)
* Default commitlog_sync_batch_window_in_ms changed to 2ms (CASSANDRA-9504)
* Fix empty partition assertion in unsorted sstable writing tools (CASSANDRA-9071)
* Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3177f15/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Frame.java b/src/java/org/apache/cassandra/transport/Frame.java
index 2868ed4..f5c3834 100644
--- a/src/java/org/apache/cassandra/transport/Frame.java
+++ b/src/java/org/apache/cassandra/transport/Frame.java
@@ -34,6 +34,8 @@ import org.apache.cassandra.transport.messages.ErrorMessage;
public class Frame
{
+ public static final byte PROTOCOL_VERSION_MASK = 0x7f;
+
public final Header header;
public final ByteBuf body;
@@ -178,7 +180,7 @@ public class Frame
int firstByte = buffer.getByte(idx++);
Message.Direction direction = Message.Direction.extractFromVersion(firstByte);
- int version = firstByte & 0x7F;
+ int version = firstByte & PROTOCOL_VERSION_MASK;
if (version > Server.CURRENT_VERSION)
throw new ProtocolException("Invalid or unsupported protocol version: " + version);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3177f15/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
index a049a57..01c0e2e 100644
--- a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
@@ -224,10 +224,17 @@ public class ErrorMessage extends Message.Response
if (e instanceof CodecException)
{
Throwable cause = e.getCause();
- if (cause != null && cause instanceof WrappedException)
+ if (cause != null)
{
- streamId = ((WrappedException)cause).streamId;
- e = cause.getCause();
+ if (cause instanceof WrappedException)
+ {
+ streamId = ((WrappedException) cause).streamId;
+ e = cause.getCause();
+ }
+ else if (cause instanceof TransportException)
+ {
+ e = cause;
+ }
}
}
else if (e instanceof WrappedException)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b3177f15/test/unit/org/apache/cassandra/transport/ProtocolErrorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/transport/ProtocolErrorTest.java b/test/unit/org/apache/cassandra/transport/ProtocolErrorTest.java
index 91f7355..9910167 100644
--- a/test/unit/org/apache/cassandra/transport/ProtocolErrorTest.java
+++ b/test/unit/org/apache/cassandra/transport/ProtocolErrorTest.java
@@ -29,6 +29,33 @@ import java.util.List;
public class ProtocolErrorTest {
@Test
+ public void testInvalidProtocolVersion() throws Exception
+ {
+ Frame.Decoder dec = new Frame.Decoder(null);
+
+ List<Object> results = new ArrayList<>();
+ // should generate a protocol exception for using a protocol version higher than the current version
+ byte[] frame = new byte[] {
+ (byte) ((Server.CURRENT_VERSION + 1) & Frame.PROTOCOL_VERSION_MASK), // direction & version
+ 0x00, // flags
+ 0x01, // stream ID
+ 0x09, // opcode
+ 0x00, 0x00, 0x00, 0x21, // body length
+ 0x00, 0x00, 0x00, 0x1b, 0x00, 0x1b, 0x53, 0x45,
+ 0x4c, 0x45, 0x43, 0x54, 0x20, 0x2a, 0x20, 0x46,
+ 0x52, 0x4f, 0x4d, 0x20, 0x73, 0x79, 0x73, 0x74,
+ 0x65, 0x6d, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x3b
+ };
+ ByteBuf buf = Unpooled.wrappedBuffer(frame);
+ try {
+ dec.decode(null, buf, results);
+ Assert.fail("Expected protocol error");
+ } catch (ProtocolException e) {
+ }
+ }
+
+ @Test
public void testInvalidDirection() throws Exception
{
Frame.Decoder dec = new Frame.Decoder(null);
@@ -51,6 +78,7 @@ public class ProtocolErrorTest {
ByteBuf buf = Unpooled.wrappedBuffer(frame);
try {
dec.decode(null, buf, results);
+ Assert.fail("Expected protocol error");
} catch (ErrorMessage.WrappedException e) {
// make sure the exception has the correct stream ID
Assert.assertEquals(1, e.getStreamId());
@@ -73,6 +101,7 @@ public class ProtocolErrorTest {
ByteBuf buf = Unpooled.wrappedBuffer(frame);
try {
dec.decode(null, buf, results);
+ Assert.fail("Expected protocol error");
} catch (ErrorMessage.WrappedException e) {
// make sure the exception has the correct stream ID
Assert.assertEquals(1, e.getStreamId());
@@ -95,6 +124,7 @@ public class ProtocolErrorTest {
ByteBuf buf = Unpooled.wrappedBuffer(frame);
try {
dec.decode(null, buf, results);
+ Assert.fail("Expected protocol error");
} catch (ErrorMessage.WrappedException e) {
// make sure the exception has the correct stream ID
Assert.assertEquals(1, e.getStreamId());
[3/3] cassandra git commit: Merge branch 'cassandra-2.2' into trunk
Posted by ty...@apache.org.
Merge branch 'cassandra-2.2' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1a14efdf
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1a14efdf
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1a14efdf
Branch: refs/heads/trunk
Commit: 1a14efdfd7137d54a9f18a809c722d467185c920
Parents: 94ff7a5 05253cc
Author: Tyler Hobbs <ty...@apache.org>
Authored: Thu Jun 4 10:20:37 2015 -0500
Committer: Tyler Hobbs <ty...@apache.org>
Committed: Thu Jun 4 10:20:37 2015 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../org/apache/cassandra/transport/Frame.java | 4 ++-
.../transport/messages/ErrorMessage.java | 13 +++++++--
.../cassandra/transport/ProtocolErrorTest.java | 30 ++++++++++++++++++++
4 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/1a14efdf/CHANGES.txt
----------------------------------------------------------------------
[2/3] cassandra git commit: Merge branch 'cassandra-2.1' into
cassandra-2.2
Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2
Conflicts:
CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/05253cc2
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/05253cc2
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/05253cc2
Branch: refs/heads/trunk
Commit: 05253cc28d572f13287e66e5200306058cac1d14
Parents: 30be921 b3177f1
Author: Tyler Hobbs <ty...@apache.org>
Authored: Thu Jun 4 10:20:09 2015 -0500
Committer: Tyler Hobbs <ty...@apache.org>
Committed: Thu Jun 4 10:20:09 2015 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../org/apache/cassandra/transport/Frame.java | 4 ++-
.../transport/messages/ErrorMessage.java | 13 +++++++--
.../cassandra/transport/ProtocolErrorTest.java | 30 ++++++++++++++++++++
4 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/05253cc2/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 43a6cc5,eea1640..0ff9363
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,24 -1,6 +1,26 @@@
-2.1.6
+2.2
+ * Add tinyint,smallint,time,date support for UDFs (CASSANDRA-9400)
+ * Deprecates SSTableSimpleWriter and SSTableSimpleUnsortedWriter (CASSANDRA-9546)
+ * Empty INITCOND treated as null in aggregate (CASSANDRA-9457)
+ * Remove use of Cell in Thrift MapReduce classes (CASSANDRA-8609)
+ * Integrate pre-release Java Driver 2.2-rc1, custom build (CASSANDRA-9493)
+ * Clean up gossiper logic for old versions (CASSANDRA-9370)
+ * Fix custom payload coding/decoding to match the spec (CASSANDRA-9515)
+ * ant test-all results incomplete when parsed (CASSANDRA-9463)
+ * Disallow frozen<> types in function arguments and return types for
+ clarity (CASSANDRA-9411)
+ * Static Analysis to warn on unsafe use of Autocloseable instances (CASSANDRA-9431)
+ * Update commitlog archiving examples now that commitlog segments are
+ not recycled (CASSANDRA-9350)
+ * Extend Transactional API to sstable lifecycle management (CASSANDRA-8568)
+ * (cqlsh) Add support for native protocol 4 (CASSANDRA-9399)
+ * Ensure that UDF and UDAs are keyspace-isolated (CASSANDRA-9409)
+ * Revert CASSANDRA-7807 (tracing completion client notifications) (CASSANDRA-9429)
+ * Add ability to stop compaction by ID (CASSANDRA-7207)
+ * Let CassandraVersion handle SNAPSHOT version (CASSANDRA-9438)
+Merged from 2.1:
+ * Use ProtocolError code instead of ServerError code for native protocol
+ error responses to unsupported protocol versions (CASSANDRA-9451)
* Default commitlog_sync_batch_window_in_ms changed to 2ms (CASSANDRA-9504)
* Fix empty partition assertion in unsorted sstable writing tools (CASSANDRA-9071)
* Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/05253cc2/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/transport/Frame.java
index 0c038ea,f5c3834..14fe589
--- a/src/java/org/apache/cassandra/transport/Frame.java
+++ b/src/java/org/apache/cassandra/transport/Frame.java
@@@ -180,11 -180,10 +182,11 @@@ public class Fram
int firstByte = buffer.getByte(idx++);
Message.Direction direction = Message.Direction.extractFromVersion(firstByte);
- int version = firstByte & 0x7F;
+ int version = firstByte & PROTOCOL_VERSION_MASK;
if (version > Server.CURRENT_VERSION)
- throw new ProtocolException("Invalid or unsupported protocol version: " + version);
+ throw new ProtocolException(String.format("Invalid or unsupported protocol version (%d); highest supported is %d ",
+ version, Server.CURRENT_VERSION));
// Wait until we have the complete V3+ header
if (version >= Server.VERSION_3 && buffer.readableBytes() < Header.MODERN_LENGTH)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/05253cc2/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java
----------------------------------------------------------------------