-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<newbie> Handling dependency injection #5142
Comments
From the code snippet you provided, I'm assuming you are getting an Fields are |
thanks @smillst. I did add |
ah - according to https://checkerframework.org/manual/#initialization-checking-suppressing-warnings it is |
|
Hi - I think I've followed the docs correctly but I can't get this to work, and it's such a simple use case that I must be missing something.
Quite simply, how do I tell the framework that something is always non null using field injection, without having to wrap each and every access with
if (!this.collaborator != null)
?I have:
The only way I can get this to work is wrapping the reference to
this.defaultDataSource
in aif (!null...)
:I can't use constructor injection, which does work, because:
Things I've tried:
javax.inject.Inject;
:-).@MonotonicNonNull
and then a@SetUp
method which asserts it isn't null@MonotonicNonNull
and adding anassert this.defaultDataSource != null
as the first line intestDataJdbc
@SuppressWarnings("initialization.fields.uninitialized")
from a StackOverflow post. Hey - we've all done it.I'm confused. What's the correct approach here? Thanks!
The text was updated successfully, but these errors were encountered: