Findbugs 'null pointer dereference' warning for ImmutableList but not for Arrays.asList

35 views Asked by At

I get 'NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Possible null pointer dereference due to return value of called method' for com.google.common.collect.ImmutableList.of(..) but not for java.util.Arrays.asList(..) for exact same input. FindBugs documentation does not mention about this difference or at least I could not locate it. Need your help understanding what is going on?

Example:

public class SomeClass{
  private String name;
  public SomeClass(String name){
  this.name=name;
 }
 public String getName(){
   return name;
 }
}
public class OtherClass{
  public void aMethod(SomeClass object){
   
  ImmutableList.of(object.getName()); // Find bugs NP warning
  Arrays.asList(object.getName()); // No warning

 }
}
0

There are 0 answers