diff --git a/router/java/src/net/i2p/router/Blocklist.java b/router/java/src/net/i2p/router/Blocklist.java index cbf3dbc6d..99247e0c2 100644 --- a/router/java/src/net/i2p/router/Blocklist.java +++ b/router/java/src/net/i2p/router/Blocklist.java @@ -147,7 +147,7 @@ public class Blocklist { _blocklistFeedFile = new File(BLOCKLIST_FEED_FILE); _haveIPv6 = TransportUtil.getIPv6Config(_context, "SSU") != TransportUtil.IPv6Config.IPV6_DISABLED && Addresses.isConnectedIPv6(); - Blocklist = _haveIPv6 ? new LHMCache(MAX_IPV6_SINGLES) : null; + _singleIPv6Blocklist = _haveIPv6 ? new LHMCache(MAX_IPV6_SINGLES) : null; } @@ -896,10 +896,12 @@ public class Blocklist { * @since IPv6 */ private boolean add(BigInteger ip) { - synchronized(_singleIPv6Blocklist) { - if (_singleIPv6Blocklist != null) + if (_singleIPv6Blocklist != null) { + synchronized(_singleIPv6Blocklist) { return _singleIPv6Blocklist.put(ip, DUMMY) == null; + } } + return false; } /** @@ -907,9 +909,10 @@ public class Blocklist { * @since 0.9.28 */ private void remove(BigInteger ip) { - synchronized(_singleIPv6Blocklist) { - if (_singleIPv6Blocklist != null) + if (_singleIPv6Blocklist != null) { + synchronized(_singleIPv6Blocklist) { _singleIPv6Blocklist.remove(ip); + } } } @@ -918,10 +921,12 @@ public class Blocklist { * @since IPv6 */ private boolean isOnSingleList(BigInteger ip) { - synchronized(_singleIPv6Blocklist) { - if (_singleIPv6Blocklist != null) + if (_singleIPv6Blocklist != null) { + synchronized(_singleIPv6Blocklist) { return _singleIPv6Blocklist.get(ip) != null; + } } + return false; } /** @@ -1365,10 +1370,12 @@ public class Blocklist { public List getTransientIPv6Blocks() { if (!_haveIPv6) return Collections.emptyList(); - synchronized(_singleIPv6Blocklist) { - if (_singleIPv6Blocklist != null) - return new ArrayList(_singleIPv6Blocklist.keySet()); + if (_singleIPv6Blocklist != null) { + synchronized(_singleIPv6Blocklist) { + return new ArrayList(_singleIPv6Blocklist.keySet()); + } } + return Collections.emptyList(); } /**