Hi
I have worked in some Findbugs issues, but still some, mostly in the services module due to the usage of ServiceContext.get() and lack of check for null value.
Possible null pointer dereference due to return value of called method
The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.
Bug kind and pattern: NP - NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
Typical usages are like this:
ServiceContext context = ServiceContext.get();
UserSession session = context.getUserSession();
ServiceContext context = ServiceContext.get();
DataManager dataManager = context.getBean(DataManager.class);
The last I’m not sure if this is really required, as long as the Spring application context is injected, I think there’s no need for this?
In any case, maybe is good to change ServiceContext.get() to throw a runtime exception if the value to return is null?
Any opinion about this or a better solution?
Btw, lets try also to run findbugs checks before any commit and if any new/updated code is affected lets fix it also.
Regards,
Jose García