This code shows warning RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
try (InputStream stream = MyClass.class.getResourceAsStream(resourceName)) {
if (stream != null) {
// code
}
} // <- warning points here
Warning message: "This method contains a redundant check of a known non-null value against the constant null."
getResourceAsStream is not null safe, as javadoc says:
@return A {@link java.io.InputStream} object; {@code null} if no
* resource with this name is found, the resource is in a package
* that is not {@linkplain Module#isOpen(String, Module) open} to at
* least the caller module, or access to the resource is denied
* by the security manager.
This code shows warning RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE
Warning message: "This method contains a redundant check of a known non-null value against the constant null."
getResourceAsStream is not null safe, as javadoc says: