While other answers on here are valid, they're not a full recipe for solving this.
In the spirit of completeness:
You need to have the findbugs annotations in your pom file - they're only compile time, so you can use the provided
scope:
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs-annotations</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
This allows the use of @SuppressFBWarnings
there is another dependency which provides @SuppressWarnings
. However, the above is clearer.
Then you add the annotation above your method:
E.g.
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
justification = "Scanning generated code of try-with-resources")
@Override
public String get() {
try (InputStream resourceStream = owningType.getClassLoader().getResourceAsStream(resourcePath);
BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream, UTF_8))) { ... }
This includes both the name of the bug and also a reason why you're disabling the scan for it.