mirror of https://github.com/apache/cassandra
Cleanup after manual review
remove decorateResponse method restore comments that are no longer applicable restore some line break changes
This commit is contained in:
parent
4f1f2d954f
commit
79af4a6e03
|
|
@ -465,6 +465,13 @@ public class CQLMessageHandler<M extends Message> 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<M extends Message> 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)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -444,12 +444,10 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer<Message.Req
|
|||
*/
|
||||
static Message.Response processRequest(Channel channel, Message.Request request, Overload backpressure, RequestTime requestTime)
|
||||
{
|
||||
Message.Response response = null;
|
||||
try
|
||||
{
|
||||
// decorateResponse must run before the finally below resets ClientWarn, so that it can read the
|
||||
// warnings accumulated during processing. Decorating in the caller (after this method returns)
|
||||
// would observe the reset state and drop all client warnings.
|
||||
return decorateResponse(processRequest((ServerConnection) request.connection(), request, backpressure, requestTime), request);
|
||||
response = processRequest((ServerConnection) request.connection(), request, backpressure, requestTime);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
|
@ -462,14 +460,17 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer<Message.Req
|
|||
}
|
||||
|
||||
Predicate<Throwable> 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<Message.Req
|
|||
flush(toFlush);
|
||||
}
|
||||
|
||||
private static Message.Response decorateResponse(Message.Response response, Message.Request request)
|
||||
{
|
||||
assert response != null;
|
||||
response.setWarnings(ClientWarn.instance.getWarnings());
|
||||
return response;
|
||||
}
|
||||
|
||||
private void flush(FlushItem<?> item)
|
||||
{
|
||||
EventLoop loop = item.channel.eventLoop();
|
||||
|
|
@ -522,7 +516,7 @@ public class Dispatcher implements CQLMessageHandler.MessageConsumer<Message.Req
|
|||
* for delivering events to registered clients is dependent on protocol version and the configuration
|
||||
* of the pipeline. For v5 and newer connections, the event message is encoded into an Envelope,
|
||||
* wrapped in a FlushItem and then delivered via the pipeline's flusher, in a similar way to
|
||||
* a Response returned from {@link #processRequest(Channel, Message.Request, FlushItemConverter, P, Overload, RequestTime)}.
|
||||
* a Response returned from {@link #processRequest(Channel, Message.Request, FlushItemConverter, Object, Overload, RequestTime)}.
|
||||
* It's worth noting that events are not generally fired as a direct response to a client request,
|
||||
* so this flush item has a null request attribute. The dispatcher itself is created when the
|
||||
* pipeline is first configured during protocol negotiation and is attached to the channel for
|
||||
|
|
|
|||
|
|
@ -277,10 +277,6 @@ public class Envelope
|
|||
// cause the channel to be closed.
|
||||
return new HeaderExtractionResult.Error(e, streamId, bodyLength);
|
||||
}
|
||||
catch (ErrorMessage.WrappedException e)
|
||||
{
|
||||
return new HeaderExtractionResult.Error((ProtocolException) e.getCause(), e.getStreamId(), bodyLength);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class HeaderExtractionResult
|
||||
|
|
|
|||
|
|
@ -122,9 +122,7 @@ public class InitialConnectionHandler extends ByteToMessageDecoder
|
|||
if (future.isSuccess())
|
||||
{
|
||||
logger.trace("Response to STARTUP sent, configuring pipeline for {}", inbound.header.version);
|
||||
configurator.configureModernPipeline(ctx, serverConnection, allocator,
|
||||
inbound.header.version,
|
||||
startup.options);
|
||||
configurator.configureModernPipeline(ctx, serverConnection, allocator, inbound.header.version, startup.options);
|
||||
allocator.release(inbound.header.bodySizeInBytes);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue