weixin_39943547 2020-11-30 01:11
浏览 0

Resurrects duplicate handlers and explains all the bugs we can make

I really don't like this in any way.

该提问来源于开源项目:openzipkin/brave

  • 写回答

7条回答 默认 最新

  • weixin_39943547 2020-11-30 01:11
    关注

    here's the problem that can sneak up on the next change to add a list parameter.

    java
    
      static class ListBindingProblems {
         List<a> as;
         List<b> bs;
    
         A provideA() {
          return new AB();
        }
      }
    
       public void listBindingProblems() {
        context.register(ListBindingProblems.class);
        context.refresh();
    
        ListBindingProblems problems = context.getBean(ListBindingProblems.class);
        assertThat(problems.as).hasSize(1);
        // eventhough the user declared their bean method provideA as returning A, spring will look at
        // all types and magically fill here. What that means is you have to be defensive about dupes,
        // or make it impossible to create dupes by type hierarchy.
        assertThat(problems.bs).hasSize(1);
      }
    </b></a>
    评论

报告相同问题?