-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Channel buffers are altered before writing to OS if exceeding Jersey's buffering size #18
Comments
Oh this is interesting; thanks for the report. I'll definitely investigate as well as I have time. |
A quick thought (which may very well be wrong): I wonder if there is something you could do with the Lines 238 to 239 in 778565b
If that's set to |
Just tested setting |
Same sort of thing, just because it's easy to try: set it to Lines 234 to 237 in 778565b
|
Well it did not change any thing, just more flushing. The buffer is already altered before flushing. |
OK. I'd like to make sure I fully understand the observed problem. You are saying: inside a JAX-RS resource, something begins writing 9K of data to an Whether Jersey is doing direct writes or not, you can see that ultimately it is sending bytes out over an I'm not sure what microbean-jersey-netty can do here. By contract, all I can supply is an Lines 222 to 228 in 778565b
This does, of course, involve creating Anyway, this write method implementation ultimately involves sending a "message" (usually a Line 255 in 778565b
I'm not sure how changing the kind of I'm not sure what else can be done or changed in this implementation. I also think maybe I'm misunderstanding you. Is there a problem here? Maybe you have found a Jersey bug? I apologize if I have not understood the issue. |
The other thing I just double-checked is that one can write directly to the So given all of that, I'm not sure how to proceed. Do you have any ideas? |
(Notes to myself.) Here is (the only place) where Jersey interacts with microbean-jersey-netty on the outbound path: In HTTP 1.1 that calls this: Lines 514 to 524 in 778565b
That calls this: Lines 256 to 324 in 778565b
…and then this: Lines 353 to 372 in 778565b
If changing the kind of |
Hmm, I wonder if this is the cause of the problem: On the Jersey thread, this This would not happen in the case where Jersey buffers, because all of the |
(More notes to myself.) OK, I think I now understand the problem. I will now see if there is an easy way to detect if the current write will be the only one, ever. If so, then no copying is needed. Otherwise copying is needed. |
OK, @scholzi100, yuck. 😄 The quickest workaround for you is—as you've already discovered—using In all other cases, because the Jersey thread is not the same as the Netty event loop thread, the A longer workaround would be to supply a custom The proper fix for all this is a breaking change, which I won't be making for now. The breaking change would be to augment the The intermediate fix is to change the default Hopefully this all makes sense. |
Finally, for completeness, there is no way (other than really retooling a lot of Jersey's innards) to avoid Lines 353 to 372 in 778565b
…rather than ignoring it (as we currently do). If, for example, |
Signed-off-by: Laird Nelson <[email protected]>
I've switched the default |
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:
Let me know if there a any further solutions.
The text was updated successfully, but these errors were encountered: