We are using Micronaut as a parent context for Spring applications, we encountered some thread pinning inside a Netty-based client. Here is a stack trace:
For now, we replaced the Netty-based implementation with the client based on Java HTTP Client (micronaut-http-client-jdk).
Steps To Reproduce
var config = new DefaultHttpClientConfiguration();
config.setFollowRedirects(false);
var httpClient = new DefaultHttpClient((URI) null, config);
var request = HttpRequest.POST(authUrl, body);
var response = httpClient.toBlocking().exchange(request, String.class); // thread will be pinned here
Expected Behavior
No thread pinning.
Actual Behaviour
We are using Micronaut as a parent context for Spring applications, we encountered some thread pinning inside a Netty-based client. Here is a stack trace:
It's because
subscribe
method usessynchronized
keyword (Here is a source code in the4.5.x
branch: https://github.com/micronaut-projects/micronaut-core/blob/1a8fc61de6ec5f78464415d642dd0227f21bc83d/http-client/src/main/java/io/micronaut/http/client/netty/CancellableMonoSink.java#L57). At this stage of Loom projects synchronized methods can lead to thread pinning, one of the suggestions to replace this keyword withReentrantLock
.For now, we replaced the Netty-based implementation with the client based on Java HTTP Client (
micronaut-http-client-jdk
).Steps To Reproduce
Environment Information
No response
Example Application
No response
Version
4.4.2