A "NullPointerException" could be thrown; "context" is nullable here
12,317
SonarQube claims that context
may be null
here. If you know this is incorrect, you could just suppress this warning as a false positive. Otherwise, you should explicitly check if context
is not null
:
if (result instanceof AsyncResult && context != null) {
// Here -------------------------^
// Make sure handle async has been called
context.handleAsync();
Result newResult = context.controllerReturned();
if (newResult != null) {
result = newResult;
}
}
Author by
P. Lisi
Updated on June 04, 2022Comments
-
P. Lisi almost 2 years
So I have an issue with SonarQube that I can not solve.
if (result instanceof AsyncResult) { // Make sure handle async has been called context.handleAsync(); Result newResult = context.controllerReturned(); if (newResult != null) { result = newResult; } }
-
zerocewl over 5 yearsWhere is the
context
variable initialized? -
akash over 5 yearsSonarQube is saying that it's possible that context can be null because it couldn't find any initialization to it. Do you want to ignore such errors?
-
-
P. Lisi over 5 yearsI solved by inserting Objects before context. Is it correct this way? Can you tell me the meaning?