From 79af4a6e033c3bd05c367cc86be6ef8151f3425a Mon Sep 17 00:00:00 2001 From: Francisco Guerrero Date: Fri, 24 Jul 2026 16:32:56 -0500 Subject: [PATCH] Cleanup after manual review remove decorateResponse method restore comments that are no longer applicable restore some line break changes --- .../transport/CQLMessageHandler.java | 13 ++++++------ .../cassandra/transport/Dispatcher.java | 20 +++++++------------ .../apache/cassandra/transport/Envelope.java | 4 ---- .../transport/InitialConnectionHandler.java | 4 +--- 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/java/org/apache/cassandra/transport/CQLMessageHandler.java b/src/java/org/apache/cassandra/transport/CQLMessageHandler.java index eec2d4d65f..4441663cfe 100644 --- a/src/java/org/apache/cassandra/transport/CQLMessageHandler.java +++ b/src/java/org/apache/cassandra/transport/CQLMessageHandler.java @@ -465,6 +465,13 @@ public class CQLMessageHandler extends AbstractMessageHandler errorHandler.accept(ErrorMessage.wrap(t, streamId)); } + /** + * For use in the case where the error can't be mapped to a specific stream id, + * such as a corrupted frame, or when extracting a CQL message from the frame's + * payload fails. This does not attempt to release any resources, as these errors + * should only occur before any capacity acquisition is attempted (e.g. on receipt + * of a corrupt frame, or failure to extract a CQL message from the envelope). + */ private void handleError(Throwable t) { errorHandler.accept(t); @@ -726,12 +733,6 @@ public class CQLMessageHandler extends AbstractMessageHandler processSubsequentFrameOfLargeMessage(frame); } - // A corrupt frame's bytes can't be reliably mapped back to a specific in-flight request (the - // frame may span several streams, and the stream id bytes may themselves be part of the - // corruption). We fall back to this connection's STARTUP stream id purely so the client still - // receives a diagnostic error frame before we tear the connection down (see the class javadoc - // above and CQLConnectionTest#handleFrameCorruptionAfterNegotiation). The exception is fatal, so - // the channel is closed as soon as the error has been written. handleError(ProtocolException.toFatalException(new ProtocolException(error))); } diff --git a/src/java/org/apache/cassandra/transport/Dispatcher.java b/src/java/org/apache/cassandra/transport/Dispatcher.java index 5c78790748..2e1b36a4f9 100644 --- a/src/java/org/apache/cassandra/transport/Dispatcher.java +++ b/src/java/org/apache/cassandra/transport/Dispatcher.java @@ -444,12 +444,10 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer handler = ExceptionHandlers.getUnexpectedExceptionHandler(channel, true); - return decorateResponse(ErrorMessage.fromExceptionNoStreamId(t, handler), request); + response = ErrorMessage.fromExceptionNoStreamId(t, handler); } finally { + if (response != null) + response.setWarnings(ClientWarn.instance.getWarnings()); CoordinatorWarnings.reset(); CoordinatorWriteWarnings.reset(); ClientWarn.instance.resetWarnings(); } + return response; } /** @@ -483,13 +484,6 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer item) { EventLoop loop = item.channel.eventLoop(); @@ -522,7 +516,7 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer