Hi I have the following method:
protected boolean shouldCheckLimit() {
if (startDate == null || endDate == null) {
return true;
}
final Long currentTime = System.currentTimeMillis();
if (startDate <= currentTime && currentTime < endDate) {
return true;
}
return false;
}
The problem is that findBugs found the following problem:
Possible null pointer dereference of TimeIntervalLimit.startDate in com.bet.blues.limit.TimeIntervalLimit.shouldCheckLimit() [Scary(8), Normal
I have to mention that startDate and endDate are Long variables. I tried to add checks for null inside if condition, also I tried to use longValue() method, but with no result. Do you have any idea how can I fix this problem? Could be a bug on fndBugs side?
startDateandendDateas parameters?shouldCheckLimit(long startDate, long endDate){}- Uma Kanthselectisn't broken. I'm having trouble believing you're getting that error with the code above, perhaps you got the error with an earlier version of the code? - T.J. CrowderstartDateandendDateare global variables. Anything can happen to them (including getting nullify) while getting the currentTime? Try the @UmaKanth suggestion and see if it fixes it. - Rosdi Kasim