-
Notifications
You must be signed in to change notification settings - Fork 16
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
Netty version update 3.9 -> 4.1 #29
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # pom.xml
Should do a major version update |
On a side note, I'm excited to try this out: https://github.com/netty/netty/tree/4.1/codec-http2 |
Our last tries showed that netty 4.1 is incompatible with spark 2.1.0. Could you please make sure, that this http-client implementation will work correctly with netty 4.0.x and 4.1.x in run time. |
@logarithm do we have a record of what the problem was? |
@drcrallen Which record do you mean? We have commit in our private repo which fixes it. Problem was that spark is using 4.0.29 netty version, but in runtime we had 4.1. and spark was failing with exception. |
pom.xml
Outdated
<artifactId>netty</artifactId> | ||
<version>3.10.6.Final</version> | ||
<artifactId>netty-all</artifactId> | ||
<version>4.1.8.Final</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why not 4.1.11?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.1.12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its release cycle is impressive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.1.13 😃
@@ -56,7 +56,7 @@ public String getEncodingString() | |||
* | |||
* @return encoding name | |||
*/ | |||
public abstract String getEncodingString(); | |||
public abstract String getEncodingString(); /*TODO use for Content-Encoding*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please file a Github/Jira issue about that
if (!headers.containsKey(HttpHeaders.Names.HOST)) { | ||
httpRequest.headers().add(HttpHeaders.Names.HOST, getHost(url)); | ||
String uri = urlFile.isEmpty() ? "/" : urlFile; | ||
final DefaultFullHttpRequest httpRequest = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested if-else instead of ternary
|
||
if (httpChunk.isLast()) { | ||
response = handler.handleChunk(response, httpChunk); | ||
if (response.isFinished() && !retVal.isDone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? Before this block was executed only if the chunk is not last
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even last chunk has content now thus it should be handled
if (response.isFinished() && !retVal.isDone()) { | ||
retVal.set((Final) response.getObj()); | ||
} | ||
ctx.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why added closing context?
AppendableByteArrayInputStream in = new AppendableByteArrayInputStream(); | ||
in.add(getContentBytes(response.getContent())); | ||
in.add(content.array()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a guarantee that the array exists? ByteBuf has hasArray()
method. Also arrayOffset()
should be considered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
) | ||
{ | ||
clientResponse.getObj().add(getContentBytes(chunk.getContent())); | ||
clientResponse.getObj().add(chunk.content().array()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
final ChannelBuffer channelBuffer = chunk.getContent(); | ||
final int bytes = channelBuffer.readableBytes(); | ||
if (bytes > 0) { | ||
if (chunk.content().hasArray()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasArray() means not that there are no bytes, it means that the ByteBuf is backed by off-heap memory.
@@ -112,7 +111,7 @@ public InputStream nextElement() | |||
Thread.currentThread().interrupt(); | |||
throw Throwables.propagate(e); | |||
} | |||
byteCount.addAndGet(bytes); | |||
byteCount.addAndGet(chunk.content().array().length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readableBytes()?
@@ -35,21 +36,22 @@ public ToStringResponseHandler(Charset charset) | |||
@Override | |||
public ClientResponse<StringBuilder> handleResponse(HttpResponse response) | |||
{ | |||
return ClientResponse.unfinished(new StringBuilder(response.getContent().toString(charset))); | |||
ByteBuf content = response instanceof HttpContent ? ((HttpContent) response).content() : Unpooled.EMPTY_BUFFER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested if-else and provide ""
empty string directly instead of converting empty buffer to empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request changes just in order to not forget to test this PR with netty 4.0.42.Final in runtime to make sure it will work with spark 2.1
@logarithm / @esevastyanov is it possible to organize the POM such that the default profile uses 4.1.x, and we have the ability to specify a profile for 4.0.x so we can test? |
Or we can just raise the issue with spark again and get the upstream on 4.1 |
To rise issue with spark looks like the best solution, but it might take time. |
@@ -123,7 +124,7 @@ public void run() | |||
// Read headers | |||
String header; | |||
while (!(header = in.readLine()).equals("")) { | |||
if (header.equals("Accept-Encoding: identity")) { | |||
if (header.toLowerCase().equals("Accept-Encoding: identity".toLowerCase())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.equalsIgnoreCase()
?
Netty was improved a lot from 3.9 to 4.1
3.x -> 4.0 http://netty.io/wiki/new-and-noteworthy-in-4.0.html
4.0 -> 4.1 http://netty.io/wiki/new-and-noteworthy-in-4.1.html