Bug: NullPointerException might be thrown as 'someList' is nullable here

1,127 views
Skip to first unread message

Anand R

unread,
Jan 12, 2017, 2:25:06 PM1/12/17
to SonarQube
Hi, 
I am using SonarLint plugin in Eclipse. I get the below-mentioned sonar warning message for the code snippet mentioned below. 

Code:
List<String> someList = null;
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(someList)){
  someList.addAll(new ArrayList());
}

Sonar message: 
NullPointerException might be thrown as 'someList' is nullable here

Versions:
Eclipse Verison: Neon Release (4.6.0)
SonarLint Version: 2.2.1
Java Version: 1.8
org.apache.commons.collections4

Tibor Blenessy

unread,
Jan 19, 2017, 6:55:55 AM1/19/17
to Anand R, SonarQube
Hello,

currently SonarJava analyzer (which is the component responsible for detecting issues in Java code) is not capable to correctly detect that someList can not be null inside the if block. We are working on this feature and if all goes well it will come in the near future. 

Best regards

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/935ec049-261f-49cd-969a-fdbc7dac9c7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Tibor BLENESSY | SonarSource
Software Engineer

monicama...@gmail.com

unread,
Aug 2, 2017, 6:30:26 AM8/2/17
to SonarQube, anan...@gmail.com
Hi
How  should I solve this issue as it is coming  under blocker issue in Sonar?
Thanks

G. Ann Campbell

unread,
Aug 2, 2017, 8:55:22 AM8/2/17
to SonarQube, anan...@gmail.com, monicama...@gmail.com
Hi,

In the meantime, you probably want to mark such issues False Positive.


Ann
Reply all
Reply to author
Forward
0 new messages