Occasionally, deadlocks occur when the main thread and asynchronous thread initialize the same Feign Api call
When I initiate a remote call for initialization using a Feign API in the main thread, and perform similar operations using the same Feign API in an asynchronous thread in the initialization of another class.
I am following org.springframework.cloud.context.named.NamedContextFactory#getContext obtains the lock, there will be a call to the context.refresh(), which in turn will contain another lock. At certain times, due to uncontrollable sequence, the main thread may experience a deadlock and fail to start.
Sample
@Component
Class A {
@PostConstruct
public void init() {
// Feign Api remote call
}
}
@Component
Class B {
@PostConstruct
public void init() {
Executors.newSingleThreadExecutor().execute(() -> {
// Same feign API calls
});
}
}
Hello @dongfangding, I was not able to reproduce it. Could you provide more details, such as a thread dump?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.