-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove usage of Netty Atomic*FieldUpdater in favor of JDKs #1317
Conversation
@slandelle heads up that without this async-http-client will be broken with the next release of Netty, see netty/netty#6130 |
Where is the 2.0 branch? 😞 |
Yeah, I was aware of that, but I was waiting for 4.1.7 to be released :)
Not created yet, as I haven't backported anything yet since upgrading master to AHC2.1/Netty4.1. Will do. |
Ow, unfortunately I am on a tight release schedule and I just cut an internal build of Netty from 4.0 branch and our application blew up unexpectedly..
|
private static final AtomicIntegerFieldUpdater<NettyResponseFuture<?>> REDIRECT_COUNT_UPDATER = newAtomicIntegerFieldUpdater(NettyResponseFuture.class, "redirectCount"); | ||
private static final AtomicIntegerFieldUpdater<NettyResponseFuture<?>> CURRENT_RETRY_UPDATER = newAtomicIntegerFieldUpdater(NettyResponseFuture.class, "currentRetry"); | ||
private static final AtomicIntegerFieldUpdater<NettyResponseFuture> REDIRECT_COUNT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(NettyResponseFuture.class, "redirectCount"); | ||
private static final AtomicIntegerFieldUpdater<NettyResponseFuture> CURRENT_RETRY_UPDATER = AtomicIntegerFieldUpdater.newUpdater(NettyResponseFuture.class, "currentRetry"); |
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 remove the <?>
? Without them, you get tons of compiler warnings.
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.
Fails to compile otherwise..
Error:(51, 137) java: incompatible types: inferred type does not conform to equality constraint(s)
inferred: org.asynchttpclient.netty.NettyResponseFuture
equality constraints(s): org.asynchttpclient.netty.NettyResponseFuture,org.asynchttpclient.netty.NettyResponseFuture
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.
Netty takes Class<? super T>
while JDK takes Class<U>
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.
and for what it's worth I didn't see any compiler warnings after removing the wildcard, maybe you could confirm with your IDE too.
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 add @SuppressWarnings("rawtypes")
annotations :)
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.
I can add it but are you absolutely sure it's necessary? my IDE and compiler are happy with it.
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.
Added.
2.0 branch published |
Thanks, I will cut an internal build of async-http-client too. |
Motivation: In later Java8 versions our Atomic*FieldUpdater are slower then the JDK implementations so we should not use ours anymore. Even worse the JDK implementations provide for example an optimized version of addAndGet(...) using intrinsics which makes it a lot faster for this use-case. Modifications: - Remove methods that return Netty Atomic*FieldUpdaters. - Use the JDK implementations everywhere. Result: Faster code.
Thanks! |
Cheers! |
Motivation: In later Java8 versions our Atomic*FieldUpdater are slower then the JDK implementations so we should not use ours anymore. Even worse the JDK implementations provide for example an optimized version of addAndGet(...) using intrinsics which makes it a lot faster for this use-case. Modifications: - Remove methods that return Netty Atomic*FieldUpdaters. - Use the JDK implementations everywhere. Result: Faster code.
cherry-picked on 2.0 as 6f53cda |
The async-http-client needs to be upgraded too, as it used an internal Netty API which has been removed in 4.0.43.Final, see [1]. [1]: AsyncHttpClient/async-http-client#1317
The async-http-client needs to be upgraded too, as it used an internal Netty API which has been removed in 4.0.43.Final, see [1]. [1]: AsyncHttpClient/async-http-client#1317
Motivation:
In later Java8 versions our Atomic*FieldUpdater are slower then the JDK implementations so we should not use ours anymore. Even worse the JDK implementations provide for example an optimized version of addAndGet(...) using intrinsics which makes it a lot faster for this use-case.
Modifications:
Result:
Faster code.