Not annotated parameter overrides @??? parameter – Spring

Photo of author
Written By M Ibrahim
intellij-idea notnull nullable spring warnings

Quick Fix: Add the same annotation (like @NotNull, @Nullable) in the child method that is present in the parent method.

The Problem:

When overriding the code open(ExecutionContext executionContext) from the org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader class, the IntelliJ IDE generates a warning stating Not annotated parameter overrides @??? parameter. The ExecutionContext executionContext parameter is annotated with @Nullable, but the overriding method does not have any annotation on its parameter. The warning suggests a potential issue with the override method due to the inconsistency in annotations.

The Solutions:

Solution 1: Fix the missing annotation

To fix the warning, you need to add the same annotation that is present on the parameter of the parent method to the parameter of the overriding method.

In this case, the parent method open from AbstractItemCountingItemStreamItemReader has a @Nullable annotation on the executionContext parameter, so you need to add the @Nullable annotation to the executionContext parameter of the open method in your overriding class.

Here is an example of how to do this:

@Override
public void open(@Nullable ExecutionContext executionContext) {
  super.open(executionContext);
}

After doing this, the warning should go away.