* NetDB: Fix NPE at startup (ticket #493)

This commit is contained in:
zzz
2011-07-08 13:46:26 +00:00
parent c7fcef2096
commit 15165aa9af

View File

@ -22,6 +22,7 @@ import net.i2p.router.RouterContext;
import net.i2p.router.peermanager.PeerProfile; import net.i2p.router.peermanager.PeerProfile;
import net.i2p.router.util.RandomIterator; import net.i2p.router.util.RandomIterator;
import net.i2p.stat.Rate; import net.i2p.stat.Rate;
import net.i2p.stat.RateStat;
import net.i2p.util.Log; import net.i2p.util.Log;
/** /**
@ -201,9 +202,12 @@ class FloodfillPeerSelector extends PeerSelector {
} else { } else {
PeerProfile prof = _context.profileOrganizer().getProfile(entry); PeerProfile prof = _context.profileOrganizer().getProfile(entry);
double maxGoodRespTime = MAX_GOOD_RESP_TIME; double maxGoodRespTime = MAX_GOOD_RESP_TIME;
Rate tunnelTestTime = _context.statManager().getRate("tunnel.testSuccessTime").getRate(10*60*1000); RateStat ttst = _context.statManager().getRate("tunnel.testSuccessTime");
if (tunnelTestTime != null && tunnelTestTime.getAverageValue() > 500) if (ttst != null) {
maxGoodRespTime = 2 * tunnelTestTime.getAverageValue(); Rate tunnelTestTime = ttst.getRate(10*60*1000);
if (tunnelTestTime != null && tunnelTestTime.getAverageValue() > 500)
maxGoodRespTime = 2 * tunnelTestTime.getAverageValue();
}
if (prof != null && prof.getDBHistory() != null if (prof != null && prof.getDBHistory() != null
&& prof.getDbResponseTime().getRate(10*60*1000).getAverageValue() < maxGoodRespTime && prof.getDbResponseTime().getRate(10*60*1000).getAverageValue() < maxGoodRespTime
&& prof.getDBHistory().getLastStoreFailed() < now - NO_FAIL_STORE_GOOD && prof.getDBHistory().getLastStoreFailed() < now - NO_FAIL_STORE_GOOD