Why does FindBugs ignore my check for null?

Can someone explain to me why this causes a findbug warning:

if (m != null && m.getModifiedDate() != null) content.put("ModifiedDate", m.getModifiedDate().getTime()); 

and it works:

 if(m != null){ Date date = m.getModifiedDate(); if (date != null) content.put("ModifiedDate", date .getTime()); } 

Warning: possible dereferencing of a null pointer due to the return value of the called method.

Is it possible to tell FindBugs that Example # 1 should not be a warning?

+8
java eclipse findbugs
source share
1 answer

Perhaps because m.getModifiedDate() can return a non-zero value for the first call, but a zero value on the second?

+15
source share

All Articles