Skip to content

Multiple @Reference annotations only have one effect #4674

@bigwg

Description

@bigwg
  • [√] I have searched the issues of this repository and believe that this is not a duplicate.
  • [√] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.3
  • Operating System version: Windows 10
  • Java version: Oracle JDK 1.8

Steps to reproduce this issue

  1. Inject a DubboService into a spring bean with @reference(async = true)
  2. Inject the same DubboService into another spring bean with @reference(async = false)
  3. Invoke the methods in these two beans

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

One bean is an asynchronous call and the other is a synchronous call

Actual Result

They are all asynchronous or synchronous

@Component("demoServiceComponent")
public class DemoServiceComponent implements DemoService {

    @Reference(async = true)
    private DemoService demoService;

    @Override
    public String sayHello(String name) {
        return demoService.sayHello(name);
    }
}

@Service("helloService")
public class HelloService {

    @Reference(async = false)
    private DemoService demoService;

    public String sayHello(String name) {
        return demoService.sayHello(name);
    }
}

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();
    DemoService service = context.getBean("demoServiceComponent", DemoServiceComponent.class);
    HelloService helloService = context.getBean("helloService", HelloService.class);
    System.out.println("result : " + service.sayHello("sync"));
    System.out.println("result : " + helloService.sayHello("async"));
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions