configuration inspection for 'never assigned field' (by ioc annotations)
For several ioc-containers you inject objects by annotations, e.g. @Autowired or @Inject.
At this point idea moans about never assigned fields. I like this check, but is it possible to take several ioc-annotations into account inside inspection configuration?
Please sign in to leave a comment.
I am seeing this with CDI based injections. I have a ServletFilter which injects a CDI bean. IDEA complains that 'Private field config is never assigned'. When I deploy the Servlet Filter and the bean class everything works fine. I am using IDEA 11.1.2 Ultimate Edition. The code looks like this:
public class MyFilter implements Filter {
@Inject
private Config config; //IDEA complains here - interestingly it also added the little coffee bean icon denoting that it sees its an injected bean
.....
public void doFilter(...) {
...
config.doSomething(); // works fine, no NPE so it is injected properly at runtime
....
}
....
}
See here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206200799-Private-field-is-never-assigned-but-it-is-