spring-cloud / spring-cloud/spring-cloud-commons

Occasionally, deadlocks occur when the main thread and asynchronous thread initialize the same Feign Api call

Open
#1,354 4 comments 0 reactions 1 assignee View on GitHub

@OlgaMaciaszek is already working on this.

Since Jun 25, 2024.

in progress
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

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
       });
   }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.