Repository: cassandra Updated Branches: refs/heads/trunk 18886e128 -> dfda97cbf
Properly handle exceptions during native proto decode Patch by Tyler Hobbs; reviewed by Aleksey Yeschenko for CASSANDRA-8118 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f16507dd Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f16507dd Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f16507dd Branch: refs/heads/trunk Commit: f16507dd1608456da0b9826b47e21c04699f0393 Parents: 5555311 Author: Tyler Hobbs <tylerho...@apache.org> Authored: Wed Oct 15 11:37:08 2014 -0500 Committer: Tyler Hobbs <tylerho...@apache.org> Committed: Wed Oct 15 11:37:08 2014 -0500 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ .../cassandra/transport/messages/ErrorMessage.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/f16507dd/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 6d9d221..0ae7af9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 2.1.1 + * Send proper error response when there is an error during native + protocol message decode (CASSANDRA-8118) * Gossip should ignore generation numbers too far in the future (CASSANDRA-8113) * Fix NPE when creating a table with frozen sets, lists (CASSANDRA-8104) * Fix high memory use due to tracking reads on incrementally opened sstable http://git-wip-us.apache.org/repos/asf/cassandra/blob/f16507dd/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 0aa54f1..7e4a3a9 100644 --- a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java @@ -18,6 +18,7 @@ package org.apache.cassandra.transport.messages; import io.netty.buffer.ByteBuf; +import io.netty.handler.codec.CodecException; import com.google.common.base.Predicate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -216,7 +217,19 @@ public class ErrorMessage extends Message.Response public static ErrorMessage fromException(Throwable e, Predicate<Throwable> unexpectedExceptionHandler) { int streamId = 0; - if (e instanceof WrappedException) + + // Netty will wrap exceptions during decoding in a CodecException. If the cause was one of our ProtocolExceptions + // or some other internal exception, extract that and use it. + if (e instanceof CodecException) + { + Throwable cause = e.getCause(); + if (cause != null && cause instanceof WrappedException) + { + streamId = ((WrappedException)cause).streamId; + e = cause.getCause(); + } + } + else if (e instanceof WrappedException) { streamId = ((WrappedException)e).streamId; e = e.getCause();