Fix PT-153072942
Ignore `$$EnhancerBySpringCGLIB$$` in determining whether a live bean corresponds to a bean defined in source-code.
This commit is contained in:
@@ -71,7 +71,7 @@ public class LiveHoverUtils {
|
||||
Stream<LiveBean> relevantBeans = beansModel.getBeansOfName(definedBean.getId()).stream();
|
||||
String type = definedBean.getType();
|
||||
if (type != null) {
|
||||
relevantBeans = relevantBeans.filter(bean -> type.equals(bean.getType()));
|
||||
relevantBeans = relevantBeans.filter(bean -> type.equals(bean.getType(true)));
|
||||
}
|
||||
return relevantBeans;
|
||||
}
|
||||
|
||||
@@ -585,4 +585,42 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void bug_153072942_SpringBootApplication__withCGLib_is_a_Component() throws Exception {
|
||||
LiveBeansModel beans = LiveBeansModel.builder()
|
||||
.add(LiveBean.builder()
|
||||
.id("demoApplication")
|
||||
.type("com.example.DemoApplication$$EnhancerBySpringCGLIB$$f378241f")
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.processId("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.boot.SpringApplication;\n" +
|
||||
"import org.springframework.boot.autoconfigure.SpringBootApplication;\n" +
|
||||
"import org.springframework.context.annotation.Bean;\n" +
|
||||
"import org.springframework.web.client.RestTemplate;\n" +
|
||||
"\n" +
|
||||
"@SpringBootApplication\n" +
|
||||
"public class DemoApplication {\n" +
|
||||
" \n" +
|
||||
"\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
" SpringApplication.run(DemoApplication.class, args);\n" +
|
||||
" }\n" +
|
||||
"}\n"
|
||||
);
|
||||
editor.assertHighlights("@SpringBootApplication");
|
||||
editor.assertHoverContains("@SpringBootApplication",
|
||||
"**Injection report for Bean [id: demoApplication, type: `com.example.DemoApplication`]**"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user