diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java index 662a5f2e6a9..8ae87a6fa53 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java @@ -453,13 +453,13 @@ public HandshakeHandler() { } @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List out) throws Exception { try { - ProtocolDetectionResult ha = HAProxyMessageDecoder.detectProtocol(in); - if (ha.state() == ProtocolDetectionState.NEEDS_MORE_DATA) { + ProtocolDetectionResult detectionResult = HAProxyMessageDecoder.detectProtocol(byteBuf); + if (detectionResult.state() == ProtocolDetectionState.NEEDS_MORE_DATA) { return; } - if (ha.state() == ProtocolDetectionState.DETECTED) { + if (detectionResult.state() == ProtocolDetectionState.DETECTED) { ctx.pipeline().addAfter(defaultEventExecutorGroup, ctx.name(), HA_PROXY_DECODER, new HAProxyMessageDecoder()) .addAfter(defaultEventExecutorGroup, HA_PROXY_DECODER, HA_PROXY_HANDLER, new HAProxyMessageHandler()) .addAfter(defaultEventExecutorGroup, HA_PROXY_HANDLER, TLS_MODE_HANDLER, tlsModeHandler); @@ -494,8 +494,8 @@ public class TlsModeHandler extends SimpleChannelInboundHandler { @Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) { - // Peek the first byte to determine if the content is starting with TLS handshake - byte b = msg.getByte(0); + // Peek the current read index byte to determine if the content is starting with TLS handshake + byte b = msg.getByte(msg.readerIndex()); if (b == HANDSHAKE_MAGIC_CODE) { switch (tlsMode) { diff --git a/store/src/main/java/org/apache/rocketmq/store/timer/Slot.java b/store/src/main/java/org/apache/rocketmq/store/timer/Slot.java index b91193b94af..2da846ceed1 100644 --- a/store/src/main/java/org/apache/rocketmq/store/timer/Slot.java +++ b/store/src/main/java/org/apache/rocketmq/store/timer/Slot.java @@ -16,9 +16,17 @@ */ package org.apache.rocketmq.store.timer; +/** + * Represents a slot of timing wheel. Format: + * ┌────────────┬───────────┬───────────┬───────────┬───────────┐ + * │delayed time│ first pos │ last pos │ num │ magic │ + * ├────────────┼───────────┼───────────┼───────────┼───────────┤ + * │ 8bytes │ 8bytes │ 8bytes │ 4bytes │ 4bytes │ + * └────────────┴───────────┴───────────┴───────────┴───────────┘ + */ public class Slot { public static final short SIZE = 32; - public final long timeMs; + public final long timeMs; //delayed time public final long firstPos; public final long lastPos; public final int num;