question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lz4FrameEncoder (and other compressors) Acknowledge Writes Too Early

See original GitHub issue

Expected behaviour: The promise for a write should be completed only once the write makes it to the network

Actual behaviour: Buffering encoders that extend MessageToByteEncoder, most notably Lz4FrameEncoder and other compressors, will notify the promise before the frame containing the message reaches the network.

This behaviour is triggered by MessageToByteEncoder.write which is designed for 1:1 conversions from message to ByteBuf. For the affected compressors, the encode method returns a ByteBuf that does not fully contain the message, unless it happens to precisely fill the buffer.

Either an empty ByteBuf is returned, or one containing only part of the message, with the remainder in both cases left in the buffer. In either case, the supplied promise will be attached to the write of this ByteBuf (empty or otherwise), and not to the ByteBuf that contains the end of the message.

Netty version: 4.0+ (I think, certainly confirmed on 4.1)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
belliottsmithcommented, Jun 27, 2019

This is definitely a bug - sorry if I should have labelled it as such at filing (not sure I have the rights to do so though)

Agreed that we should extend MessageToByteEncoder

A more “correct” fix would be to standardise the buffering encoders on a class that can handle the buffering for them. But something like what you propose is certainly easier and less invasive. I’ll take a look at rustling up a candidate soon.

0reactions
belliottsmithcommented, Oct 11, 2019

Sorry @normanmaurer, I did not and since forgot. It turns out it’s harder to keep up with your regular responsibilities when you’re distracted by a cute baby in your personal time.

I’d still be willing to take a look, but you might have to bear with me another few weeks. Please don’t feel like you’re treading on my toes if you or somebody else wants to address it though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lz4FrameEncoder compression failure behavior #6248 - GitHub
If Lz4FrameEncoder encounters an error during compression the buffered content is left untouched and an exception is thrown [1].
Read more >
Lz4FrameEncoder (Netty API Reference (4.1.85.Final))
Returns true if and only if the compressed stream has been finished. Methods inherited from class io.netty.handler.codec.MessageToByteEncoder.
Read more >
Reciprocating Compressor Basics - Machinery Lubrication
A reciprocating compressor is a positive-displacement machine that uses a piston to compress a gas and deliver it at high pressure.
Read more >
Applications of Air Compressors | How to Use
Air compressors can be used for leisure and maintenance at home or in businesses to get work done efficiently and safely.
Read more >
Common Problems with Air Compressors - The Titus Company
In other cases, the compressor might fail to start up or stop running as ... need to take a look at it or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found