-
Notifications
You must be signed in to change notification settings - Fork 2
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
Netty5.x Multipart Codec for Netty Contrib #1
Conversation
Hi, Could you please take a look at this PR ? This PR is now functional, where the old benchmark and the old examples from 4.1.x are also ported. There are still rooms for enhancements, but I have created separate PRs which can be addressed separately (later):
thank you. |
…methods. Added tests for HttpData send. Benchmark resource leak detector is now configurable from the JMH jmv options, because I can't make it working as it was done in previous 4.x version.
Could one of you kindly review this PR please? Indeed, we have another PR in Reactor-Netty that is pending and it depends on this PR in order reintegrate multipart using Netty5. This PR is proposing a variant of the old API, but I'll be happy to finalise it in case you think there are problems with the proposed API changes. Now, there is still room for enhancements, but I have created separate PRs which can be addressed separately (later):
thanks ! |
@pderop I don't think we (Norman and I) have the bandwidth to help out with http multipart. I think you have the ability to merge it yourself, right? You can of course ask others in the community if you want more eyes on it. |
Ok, then I will see if someone else from the community would like to review this PR before I merge it. |
The PR has been integrated in reactor-netty draft PR (reactor/reactor-netty#2327), and from discord, there is a feedback regarding scalability of instanceof checks (I have created the #10 PR in order to investigate this a bit later). So, In the meantime, let's merge this PR into main. |
This is the initial port of the Netty 4.x multipart codec into netty5 contrib.
Motivation
This PR is an attempt to port the current Netty 4.1.80.Final-SNAPSHOT Multipart codec to the Netty 5.0.0-Alpha5 version.
Modifications
Mainly, bellow are the proposed changes that have been done (to be discussed :-)):
InterfaceHttpData.java
Before this interface was extending ReferenceCounted with the following methods:
Now, the interface is now extending Resource, and the above methods are replaced by:
So, we now have:
HttpData.java
The HttpData interface does not extend the ByteBufHolder anymore, so, the following methods:
are replaced by:
AbstractHttpData.java
The AbstractHttpData does not extend the AbstractReferenceCounted anymore. It instead extends ResourceSupport<HttpData, AbstractHttpData> in order to make it easier to implement the Resource interface. A Drop static inner class is now used to ensure that the HttpData.delete() method is invoked when the resource is closed.
The old AbstractReferenceCounted methods have been removed:
The content can now be obtained using content() method which is now returning a Buffer:
HttpPostMultipartRequestDecoder.java
Before, the offer(HttpContent content) method was doing this check in order to possibly discard undecoded chunks:
now it is assumed that the content ownership is transferred to the MP codec, so the above code has been replaced by:
Note: it may make sense to change the offer(HttpContent content) signature by offer(Send<HttpContent> content), in order to enforce the fact that the ownership is really transferred to the API. See below TODO section.
HttpPostStandardRequestDecoder.java:
The parseBodyAttributes method was using old ByteBuf.array() method in order to optimize parsing of body attributes, like this:
So, in the porting, the optimization has been removed because the Buffer API does not provide the byte array anymore,
and only the parseBodyAttributesStandard() has been kept in the new version:
However, we can probably optimize the parseBodyAttributesStandard method with Cursors.
Result
The tests are passing, the new multipart codec is now based on netty5 buffers, and does not depend anymore on ByteBuf API.
Current status and improvements
Old multipart PRs from 4.1.80.Final-SNAPSHOT are merged, but there is still room for enhancements. I have created other PRs which can be addressed separately: