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 — MQTT: Make the decodeProperties early-REPLAY check actually fire (#16… · netty/netty@2d781e2

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
@@ -749,9 +749,14 @@ private static Result<MqttProperties> decodeProperties(ByteBuf buffer) {
749749
final long propertiesLength = decodeVariableByteInteger(buffer);
750750
int totalPropertiesLength = unpackA(propertiesLength);
751751
int numberOfBytesConsumed = unpackB(propertiesLength);
752-
if (buffer.readableBytes() < totalPropertiesLength) {
753-
// Force an early REPLAY to avoid repeatedly parsing the properties.
754-
buffer.readSlice(totalPropertiesLength);
752+
if (totalPropertiesLength > 0) {
753+
// Force an early REPLAY when the buffer does not yet have the full properties block,
754+
// so we don't repeatedly parse partial properties as data arrives. A direct
755+
// buffer.readableBytes() check is unusable here because ReplayingDecoderByteBuf
756+
// returns Integer.MAX_VALUE - readerIndex; touching the last byte via getByte()
757+
// routes through ReplayingDecoderByteBuf.checkIndex(), which throws REPLAY if the
758+
// buffer's writerIndex hasn't reached that position yet.
759+
buffer.getByte(buffer.readerIndex() + totalPropertiesLength - 1);
755760
}
756761

757762
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.