I'm working on a servlet. And the response argument is throwing the below sonar issue.
Not annotated parameter overrides @notnull parameter
How can I deal with this?
Solved! Go to Solution.
Views
Replies
Total Likes
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.
Please try
import org.jetbrains.annotations.NotNull;
@Override
protected void doGet(final @NotNull SlingHttpServletRequest request,
final @NotNull SlingHttpServletResponse response) throws ServletException, IOException
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.
Please try
import org.jetbrains.annotations.NotNull;
@Override
protected void doGet(final @NotNull SlingHttpServletRequest request,
final @NotNull SlingHttpServletResponse response) throws ServletException, IOException
@goyalkritika The Sonar issue you mentioned, "Not annotated parameter overrides @NotNull parameter," indicates that you have a method in your servlet that overrides a method from a superclass or interface, and the overridden method has a parameter annotated with @NotNull to indicate that it cannot be null. However, in your overriding method, you have not provided the @NotNull annotation for the corresponding parameter.
Here's an example of how you can add the @NotNull annotation to your parameter in the servlet method:
@Override
public void doGet(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response)
{ // Servlet code }
Views
Replies
Total Likes