spring-projects / spring-security

Spring Security
http://spring.io/projects/spring-security
Apache License 2.0
8.86k stars 5.92k forks source link

Polish use getBeanProvider instead of getBeanNamesForType and getBean #15950

Closed kse-music closed 1 month ago

kse-music commented 1 month ago
  1. Use getBeanProvider instead of the similar code below
    if (this.context.getBeanNamesForType(A.class).length > 0) {
        this.bearerTokenResolver = this.context.getBean(A.class);
    }
    else {
        this.bearerTokenResolver = new A();
    }
  1. In addition, also can avoid run error when define multiple Bean in contexts