Skip to content

Channel buffers are altered before writing to OS if exceeding Jersey's buffering size #18

@scholzi100

Description

@scholzi100

Current unit tests only test a very small content transfers from the server to client and visa-versa. I added a test sending lots of data (multiple megabytes), soon I noticed that the content was not received as created in JAX-RS.

After some testing, I switched the ByteBufCreator from Unpooled.wrappedBuffer to Unpooled.copiedBuffer, this made the test work.
I did some searching and found out that http body content does only get corrupted after going over 8192 bytes (Jersey's default buffering size in CommittingOutputStream). Adding a trace log to the ByteBufCreator revealed that after going over the buffer size, Jersey uses direct writing (from the same byte array rest.log). I created a test over at scholzi100@68394b5 as a prototype, checking this behaviour.

This some what breaks the one of the main features "no copying of byte arrays", the current solutions I see are:

  • turn the Jersey buffer to a massive size
  • using Unpooled.copiedBuffer as default ByteBufCreator (and turning Jersey buffering off by default)
  • some how skip CommittingOutputStream (to reduce coping from and to it) and directly copying to Netty's ByteBuf

Let me know if there a any further solutions.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions