-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext #108374
Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext #108374
Conversation
@@ -568,11 +568,9 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th | |||
} | |||
}; | |||
// there's only one netty worker thread that's reused across client requests | |||
Settings settings = Settings.builder() | |||
.put(Netty4Plugin.WORKER_COUNT.getKey(), 1) | |||
Settings settings = createBuilderWithPort().put(Netty4Plugin.WORKER_COUNT.getKey(), 1) |
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 think this is the problem. I think the error we're seeing in #108193 is an exception due to an RST state for the socket.
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.
You are right. Funnily, this was the first thing I tried. Not sure why it failed for me before, but I re-tested it now and it passes without exceptions.
for (int i = 0; i < nRetries; i++) { | ||
acceptChannel.set(randomBoolean()); | ||
try (Netty4HttpClient client = new Netty4HttpClient()) { | ||
try (Netty4HttpClient client = new Netty4HttpClient()) { |
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.
Alternatively, I think it's "better" to reuse the client. If there is context pollution, it will first show up across different requests from the same client, before leaking across clients (because clients are statically assigned to a single thread).
.put(Netty4Plugin.SETTING_HTTP_WORKER_COUNT.getKey(), 0) | ||
.build(); | ||
NioEventLoopGroup group = new NioEventLoopGroup(); |
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.
This was not used.
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.
LGTM 👍
…eadContext (elastic#108374) Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext
Fix Netty4HttpServerTransportTests testChannelAcceptorCannotTamperThreadContext
Closes #108193