GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Auto-port 4.2: MQTT: Make the decodeProperties early-REPLAY check act… · netty/netty@bfbdc4e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-mqtt/src/main/java/io/netty/handler/codec/mqtt
    • MqttDecoder.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java‎

Copy file name to clipboardExpand all lines: codec-mqtt/src/main/java/io/netty/handler/codec/mqtt/MqttDecoder.java
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,14 @@ private static Result<MqttProperties> decodeProperties(ByteBuf buffer) {
780780
final long propertiesLength = decodeVariableByteInteger(buffer);
781781
int totalPropertiesLength = unpackA(propertiesLength);
782782
int numberOfBytesConsumed = unpackB(propertiesLength);
783-
if (buffer.readableBytes() < totalPropertiesLength) {
784-
// Force an early REPLAY to avoid repeatedly parsing the properties.
785-
buffer.readSlice(totalPropertiesLength);
783+
if (totalPropertiesLength > 0) {
784+
// Force an early REPLAY when the buffer does not yet have the full properties block,
785+
// so we don't repeatedly parse partial properties as data arrives. A direct
786+
// buffer.readableBytes() check is unusable here because ReplayingDecoderByteBuf
787+
// returns Integer.MAX_VALUE - readerIndex; touching the last byte via getByte()
788+
// routes through ReplayingDecoderByteBuf.checkIndex(), which throws REPLAY if the
789+
// buffer's writerIndex hasn't reached that position yet.
790+
buffer.getByte(buffer.readerIndex() + totalPropertiesLength - 1);
786791
}
787792

788793
MqttProperties decodedProperties = new MqttProperties();

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.