diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 7b6e7b51cd..f259e3e1fc 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -282,8 +282,7 @@ public synchronized void shutdown() { if (_ds != null) _ds.stop(); _exploreKeys.clear(); - if (_negativeCache != null) - _negativeCache.clear(); + negativeCache().clear(); if (isMainDb()) blindCache().shutdown(); } @@ -803,8 +802,7 @@ public Destination lookupDestinationLocally(Hash key) { return ls.getDestination(); } } else { - if (_negativeCache != null) - return _negativeCache.getBadDest(key); + return negativeCache().getBadDest(key); } return null; } @@ -1516,8 +1514,7 @@ protected void lookupBeforeDropping(Hash peer, RouterInfo info) { */ void dropAfterLookupFailed(Hash peer) { _context.peerManager().removeCapabilities(peer); - if (_negativeCache != null) - _negativeCache.cache(peer); + negativeCache().cache(peer); _kb.remove(peer); //if (removed) { // if (_log.shouldLog(Log.INFO)) @@ -1659,8 +1656,7 @@ else if (responseTime < MIN_PER_PEER_TIMEOUT) * @since 0.9.4 moved from FNDF to KNDF in 0.9.16 */ void lookupFailed(Hash key) { - if (_negativeCache != null) - _negativeCache.lookupFailed(key); + negativeCache().lookupFailed(key); } /** @@ -1670,9 +1666,7 @@ void lookupFailed(Hash key) { * @since 0.9.4 moved from FNDF to KNDF in 0.9.16 */ boolean isNegativeCached(Hash key) { - if (_negativeCache == null) - return false; - boolean rv = _negativeCache.isCached(key); + boolean rv = negativeCache().isCached(key); if (rv) _context.statManager().addRateData("netDb.negativeCache", 1); return rv; @@ -1683,9 +1677,7 @@ boolean isNegativeCached(Hash key) { * @since 0.9.16 */ void failPermanently(Destination dest) { - if (_negativeCache != null) - return; - _negativeCache.failPermanently(dest); + negativeCache().failPermanently(dest); } /** @@ -1695,9 +1687,7 @@ void failPermanently(Destination dest) { * @since 0.9.16 */ public boolean isNegativeCachedForever(Hash key) { - if (_negativeCache != null) - return false; - return _negativeCache.getBadDest(key) != null; + return negativeCache().getBadDest(key) != null; } /** @@ -1708,4 +1698,11 @@ public boolean isNegativeCachedForever(Hash key) { public void renderStatusHTML(Writer out) throws IOException { out.write(_kb.toString().replace("\n", "
\n")); } + + private NegativeLookupCache negativeCache() { + if (_negativeCache != null) + return _negativeCache; + KademliaNetworkDatabaseFacade kndf = (KademliaNetworkDatabaseFacade) _context.netDb(); + return kndf.negativeCache(); + } }