嗨,我有以下方法:
protected boolean shouldCheckLimit() {
if (startDate == null || endDate == null) {
return true;
}
final Long currentTime = System.currentTimeMillis();
if (startDate <= currentTime && currentTime < endDate) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
问题是findBugs发现了以下问题:
Possible null pointer dereference of TimeIntervalLimit.startDate in com.bet.blues.limit.TimeIntervalLimit.shouldCheckLimit() [Scary(8), Normal
Run Code Online (Sandbox Code Playgroud)
我必须提到startDate和endDate是Long变量.我尝试在条件中添加null的检查,我也尝试使用longValue()方法,但没有结果.你知道如何解决这个问题吗?可能是fndBugs方面的错误?
你得到错误,因为startDate(也endDate可能)null.但是你检查了它们null,所以这是不可能的,对吧?
答案是两者都是全局的,可能null在任何时候由另一个线程设置.
| 归档时间: |
|
| 查看次数: |
1384 次 |
| 最近记录: |