Explanation
Although I can't reproduce this on AbstractItemCountingItemStreamItemReader
from this artifact
implementation group: 'org.springframework.batch', name: 'spring-batch-core', version: '4.1.2.RELEASE'
, this annotation means that the parent method has some @NotNull
/ @NonNull
annotation on the parameter, while the overriding method has no.
To fix it, you need to put the same annotation on the overriding method.
As I wrote, there is no such annotation in the version I've downloaded, but check your sources and copy the parameter annotation from there.
This warning sometimes gets buggy, so it can help to restart the IDEA. Restarting helped when I tried to write a trivial example to reproduce the warning.
A trivial reproducible example
Parent class:
package com.dpopov.java.stackoverflow;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
public class ParentClass {
public void nonNullMethod(@NonNull String string) {
System.out.println("S is: " + string);
}
public void nullMethod(@Nullable String string) {
System.out.println("S is: " + string);
}
}
Child class:
package com.dpopov.java.stackoverflow;
public class NonNullOverride extends ParentClass {
public static void main(String[] args) {
NonNullOverride nonNullOverride = new NonNullOverride();
nonNullOverride.nonNullMethod(null);
nonNullOverride.nullMethod(null);
}
@Override
public void nonNullMethod(final String string) {
super.nonNullMethod(string);
if (string.equals("666")) {
System.out.println("yes");
}
}
@Override
public void nullMethod(final String string) {
super.nullMethod(string);
if (string == null) {
System.out.println("I am null, it can be.");
return;
}
if (string.equals("666")) {
System.out.println("yes");
}
}
}
To be 100%-sure, I've added org.springframework.lang.NonNull
and org.springframework.lang.Nullable
annotations to the appropriate Nullable
/ NonNull
annotations of the inspection Java | Probable bugs | @NotNull/@Nullable problems
(in File | Settings | Editor | Inspections
). You do this by pressing Configure annotations
button (see the screenshot).

- As a result, I've got the warning on child's class
#nonNullMethod
:

- Specially note that non-annotating
@Nullable
method does not provoke any warning.
- Warning only worked after IDEA restart.
- The whole inspection looks to work pretty buggy, if you turn on/off the checkboxes in the inspection settings and try to reproduce them. So, again, restarting/invalidating caches may help to get rid or show the incorrect warning.