spotbugs / spotbugs

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

Home Page:https://spotbugs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Treat `@PostConstruct` methods as constructors for `UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR`

famod opened this issue · comments

Very similar to #453.

As of SB 4.8.3, UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR is reported for the following class:

// CDI bean
@ApplicationScoped
puplic class Foo {
    private Object bar;

    @PostConstruct
    void init() {
        bar = new Object();
    }

    public String doSomethingWithBar() {
        return bar.toString();
    }
}

This will never be a problem during runtime (only maybe in simple tests that don't use CDI, but you'll notice soon enough).

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.