Skip to content

Message with empty body is not properly decoded #52

@nathanfallet

Description

@nathanfallet

When a message has an empty body, it waits for the body frame forever (which is never sent by the broker). So we should return as early as we get the header with the bodySize being 0.

Test code to reproduce the issue:

func testBasicGetWithZeroBytesPayload() async throws {
    let channel = try await connection.openChannel()

    try await channel.queueDeclare(name: "test", durable: true)

    let body = ByteBufferAllocator().buffer(string: "")

    try await channel.basicPublish(from: body, exchange: "", routingKey: "test")

    guard let msg = try await channel.basicGet(queue: "test") else {
        return  XCTFail()
    }

    XCTAssertEqual(msg.messageCount, 0)
    XCTAssertEqual(msg.message.body.getString(at: 0, length: msg.message.body.readableBytes), "")

    try await channel.queueDelete(name: "test")

    try await channel.close()
}

Same as guimauvedigital/kourier#9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions