-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clarify when returned values might be null #358
Comments
Thanks for raising the issue. The omission of "never null" from the Javadoc for |
Thanks! I thought that might be the case ... and for ParameterResolvers, just that little sentence makes a huge difference since (almost) every supports() and resolve() call wants access to the parameter. (Plus I love it when my code base shrinks) |
See #741 for additional motivation to use annotations to support static analysis and Kotlin interoperability. |
Define a package-level `@NonNullApi` annotation, apply it to all packages, and annotate parameters and methods that may be null with `@Nullable`. Issue: #358
Inspired by IntelliJ complaining about @junit-team/junit-lambda WDYT, should we do this for the whole codebase? |
@marcphilipp By my understanding, |
@jbduncan commented on the difference between JSR-305 static analysis and the Checker Framework in #961 (comment). If an internal |
@smoyer64 Could you please elaborate on that "plug-in" option? |
Both the Checker Framework and Error-Prone allow you to write custom |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you have a good use case for this feature, please feel free to reopen the issue. |
When the
ParameterResolver
'ssupports()
andresolve()
methods were changed to useParameterContext
, the statement that theParameter
was nevernull
was replaced by text that statedParamterResolver
is never null.ParameterResolver
itself makes no assertion that getParameter() always returns a non-null value. Thus, I'm now checking for null parameters as follows:For the
ParameterContext
, it wouldn't make sense to ever have a non-null parameter (otherwise it would be aSomethingElseContext
), so this code is probably completely unnecessary. As a defensive coder, I put it in anyway. Here are my recommendations in order of priority/complexity:Optional
when a return type might benull
.null
.@CheckForNull
,@Nonnull
and@Nullable
to all public APIs.I know the JUnit team's policy on avoiding dependencies - adding JSR-305 as provided allows those of us who chose to perform static analysis on our Engine, Extension and test code to choose to add the dependency to our classpath.
Related Resources
The text was updated successfully, but these errors were encountered: