commit c47806764c69eaf246cbc9032d2dbaba7ca95a8e Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Jan 10 15:16:39 2017 +0100
Use diamond operator. --- .../torproject/onionoo/docs/BandwidthStatus.java | 9 +-- .../onionoo/docs/ClientsGraphHistory.java | 2 +- .../torproject/onionoo/docs/ClientsHistory.java | 2 +- .../org/torproject/onionoo/docs/ClientsStatus.java | 6 +- .../torproject/onionoo/docs/DateTimeHelper.java | 2 +- .../org/torproject/onionoo/docs/DetailsStatus.java | 2 +- .../org/torproject/onionoo/docs/DocumentStore.java | 32 ++++---- .../org/torproject/onionoo/docs/NodeStatus.java | 40 +++++----- .../torproject/onionoo/docs/SummaryDocument.java | 4 +- .../org/torproject/onionoo/docs/UptimeHistory.java | 2 +- .../org/torproject/onionoo/docs/UptimeStatus.java | 11 +-- .../org/torproject/onionoo/docs/WeightsStatus.java | 3 +- .../onionoo/server/MostFrequentString.java | 7 +- .../org/torproject/onionoo/server/NodeIndexer.java | 43 ++++------ .../torproject/onionoo/server/RequestHandler.java | 35 ++++---- .../torproject/onionoo/server/ResourceServlet.java | 8 +- .../torproject/onionoo/server/ResponseBuilder.java | 6 +- .../onionoo/updater/ClientsStatusUpdater.java | 5 +- .../onionoo/updater/DescriptorDownloader.java | 4 +- .../onionoo/updater/DescriptorQueue.java | 5 +- .../onionoo/updater/DescriptorSource.java | 5 +- .../torproject/onionoo/updater/LookupService.java | 21 +++-- .../onionoo/updater/NodeDetailsStatusUpdater.java | 93 +++++++++------------- .../onionoo/updater/ReverseDomainNameResolver.java | 10 +-- .../onionoo/updater/UptimeStatusUpdater.java | 25 +++--- .../onionoo/updater/WeightsStatusUpdater.java | 17 ++-- .../onionoo/writer/BandwidthDocumentWriter.java | 7 +- .../onionoo/writer/ClientsDocumentWriter.java | 22 +++-- .../onionoo/writer/DetailsDocumentWriter.java | 17 ++-- .../onionoo/writer/SummaryDocumentWriter.java | 2 +- .../onionoo/writer/UptimeDocumentWriter.java | 19 ++--- .../onionoo/writer/WeightsDocumentWriter.java | 7 +- .../onionoo/docs/BandwidthStatusTest.java | 3 +- .../onionoo/docs/DummyDocumentStore.java | 5 +- .../torproject/onionoo/docs/NodeStatusTest.java | 6 +- .../onionoo/docs/SummaryDocumentTest.java | 6 +- .../torproject/onionoo/docs/UptimeStatusTest.java | 2 +- .../onionoo/server/ResourceServletTest.java | 26 +++--- .../torproject/onionoo/updater/DummyConsensus.java | 2 +- .../onionoo/updater/DummyDescriptorSource.java | 5 +- .../onionoo/updater/DummyStatusEntry.java | 2 +- .../onionoo/updater/LookupServiceTest.java | 70 ++++++++-------- 42 files changed, 257 insertions(+), 343 deletions(-)
diff --git a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java index 580bfbd..911af2a 100644 --- a/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java @@ -29,8 +29,7 @@ public class BandwidthStatus extends Document { this.isDirty = false; }
- private SortedMap<Long, long[]> writeHistory = - new TreeMap<Long, long[]>(); + private SortedMap<Long, long[]> writeHistory = new TreeMap<>();
public void setWriteHistory(SortedMap<Long, long[]> writeHistory) { this.writeHistory = writeHistory; @@ -40,8 +39,7 @@ public class BandwidthStatus extends Document { return this.writeHistory; }
- private SortedMap<Long, long[]> readHistory = - new TreeMap<Long, long[]>(); + private SortedMap<Long, long[]> readHistory = new TreeMap<>();
public void setReadHistory(SortedMap<Long, long[]> readHistory) { this.readHistory = readHistory; @@ -117,8 +115,7 @@ public class BandwidthStatus extends Document { }
private void compressHistory(SortedMap<Long, long[]> history) { - SortedMap<Long, long[]> uncompressedHistory = - new TreeMap<Long, long[]>(history); + SortedMap<Long, long[]> uncompressedHistory = new TreeMap<>(history); history.clear(); long lastStartMillis = 0L; long lastEndMillis = 0L; diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java b/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java index df538a9..6b2bd3d 100644 --- a/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java +++ b/src/main/java/org/torproject/onionoo/docs/ClientsGraphHistory.java @@ -59,7 +59,7 @@ public class ClientsGraphHistory { return this.count; }
- private List<Integer> values = new ArrayList<Integer>(); + private List<Integer> values = new ArrayList<>();
public void setValues(List<Integer> values) { this.values = values; diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java index e1f0353..c1c93fd 100644 --- a/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java +++ b/src/main/java/org/torproject/onionoo/docs/ClientsHistory.java @@ -117,7 +117,7 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
private static SortedMap<String, Double> parseResponses( String responsesString) { - SortedMap<String, Double> responses = new TreeMap<String, Double>(); + SortedMap<String, Double> responses = new TreeMap<>(); if (responsesString.length() > 0) { for (String pair : responsesString.split(",")) { String[] keyValue = pair.split("="); diff --git a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java index 55bdc7b..cfc424e 100644 --- a/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/ClientsStatus.java @@ -27,8 +27,7 @@ public class ClientsStatus extends Document { this.isDirty = false; }
- private SortedSet<ClientsHistory> history = - new TreeSet<ClientsHistory>(); + private SortedSet<ClientsHistory> history = new TreeSet<>();
public void setHistory(SortedSet<ClientsHistory> history) { this.history = history; @@ -73,8 +72,7 @@ public class ClientsStatus extends Document { /** Compresses the history of clients objects by merging adjacent * intervals, depending on how far back in the past they lie. */ public void compressHistory() { - SortedSet<ClientsHistory> uncompressedHistory = - new TreeSet<ClientsHistory>(this.history); + SortedSet<ClientsHistory> uncompressedHistory = new TreeSet<>(this.history); history.clear(); ClientsHistory lastResponses = null; String lastMonthString = "1970-01"; diff --git a/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java b/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java index 9721612..7a63f53 100644 --- a/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java +++ b/src/main/java/org/torproject/onionoo/docs/DateTimeHelper.java @@ -78,7 +78,7 @@ public class DateTimeHelper { }
protected Map<String, DateFormat> initialValue() { - return new HashMap<String, DateFormat>(); + return new HashMap<>(); }
public void remove() { diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java index bad3964..0a0c215 100644 --- a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java @@ -255,7 +255,7 @@ public class DetailsStatus extends Document { * includes the primary address and all additionally configured * onion-routing addresses. */ public SortedSet<String> getOrAddresses() { - SortedSet<String> orAddresses = new TreeSet<String>(); + SortedSet<String> orAddresses = new TreeSet<>(); if (this.address != null) { orAddresses.add(this.address); } diff --git a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java index 08fb984..39d6271 100644 --- a/src/main/java/org/torproject/onionoo/docs/DocumentStore.java +++ b/src/main/java/org/torproject/onionoo/docs/DocumentStore.java @@ -115,15 +115,14 @@ public class DocumentStore { this.cacheNodeStatuses(); } if (updatedAfter >= this.lastModifiedNodeStatuses) { - return new TreeSet<String>(this.updatedNodeStatuses); + return new TreeSet<>(this.updatedNodeStatuses); } else { - return new TreeSet<String>(this.cachedNodeStatuses.keySet()); + return new TreeSet<>(this.cachedNodeStatuses.keySet()); } }
private void cacheNodeStatuses() { - SortedMap<String, NodeStatus> parsedNodeStatuses = - new TreeMap<String, NodeStatus>(); + SortedMap<String, NodeStatus> parsedNodeStatuses = new TreeMap<>(); File directory = this.statusDir; if (directory != null) { File summaryFile = new File(directory, "summary"); @@ -150,7 +149,7 @@ public class DocumentStore { } } this.cachedNodeStatuses = parsedNodeStatuses; - this.updatedNodeStatuses = new TreeSet<String>(); + this.updatedNodeStatuses = new TreeSet<>(); }
private SortedSet<String> listSummaryDocuments(long updatedAfter) { @@ -158,15 +157,14 @@ public class DocumentStore { this.cacheSummaryDocuments(); } if (updatedAfter >= this.lastModifiedSummaryDocuments) { - return new TreeSet<String>(this.updatedSummaryDocuments); + return new TreeSet<>(this.updatedSummaryDocuments); } else { - return new TreeSet<String>(this.cachedSummaryDocuments.keySet()); + return new TreeSet<>(this.cachedSummaryDocuments.keySet()); } }
private void cacheSummaryDocuments() { - SortedMap<String, SummaryDocument> parsedSummaryDocuments = - new TreeMap<String, SummaryDocument>(); + SortedMap<String, SummaryDocument> parsedSummaryDocuments = new TreeMap<>(); if (this.outDir != null) { File summaryFile = new File(this.outDir, "summary"); if (summaryFile.exists()) { @@ -198,12 +196,12 @@ public class DocumentStore { } } this.cachedSummaryDocuments = parsedSummaryDocuments; - this.updatedSummaryDocuments = new TreeSet<String>(); + this.updatedSummaryDocuments = new TreeSet<>(); }
private <T extends Document> SortedSet<String> listDocumentFiles( Class<T> documentType, long updatedAfter) { - SortedSet<String> fingerprints = new TreeSet<String>(); + SortedSet<String> fingerprints = new TreeSet<>(); File directory = null; String subdirectory = null; if (documentType.equals(DetailsStatus.class)) { @@ -238,7 +236,7 @@ public class DocumentStore { subdirectory = "uptimes"; } if (directory != null && subdirectory != null) { - Stack<File> files = new Stack<File>(); + Stack<File> files = new Stack<>(); files.add(new File(directory, subdirectory)); while (!files.isEmpty()) { File file = files.pop(); @@ -418,7 +416,7 @@ public class DocumentStore { boolean isRelay = detailsDocument.getHashedFingerprint() == null; boolean running = false; String nickname = detailsDocument.getNickname(); - List<String> addresses = new ArrayList<String>(); + List<String> addresses = new ArrayList<>(); String countryCode = null; String asNumber = null; String contact = null; @@ -443,7 +441,7 @@ public class DocumentStore { } } } - SortedSet<String> relayFlags = new TreeSet<String>(); + SortedSet<String> relayFlags = new TreeSet<>(); SortedSet<String> family = null; long lastSeenMillis = -1L; long consensusWeight = -1L; @@ -727,10 +725,8 @@ public class DocumentStore { return; } File summaryFile = new File(directory, "summary"); - SortedMap<String, NodeStatus> cachedRelays = - new TreeMap<String, NodeStatus>(); - SortedMap<String, NodeStatus> cachedBridges = - new TreeMap<String, NodeStatus>(); + SortedMap<String, NodeStatus> cachedRelays = new TreeMap<>(); + SortedMap<String, NodeStatus> cachedBridges = new TreeMap<>(); for (Map.Entry<String, NodeStatus> e : this.cachedNodeStatuses.entrySet()) { if (e.getValue().isRelay()) { diff --git a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java index a2b44f8..7e4e438 100644 --- a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java @@ -76,7 +76,7 @@ public class NodeStatus extends Document { }
private SortedSet<String> stringArrayToSortedSet(String[] stringArray) { - SortedSet<String> sortedSet = new TreeSet<String>(); + SortedSet<String> sortedSet = new TreeSet<>(); if (stringArray != null) { sortedSet.addAll(Arrays.asList(stringArray)); } @@ -137,7 +137,7 @@ public class NodeStatus extends Document { * includes the primary address and all additionally configured * onion-routing addresses. */ public SortedSet<String> getOrAddresses() { - SortedSet<String> orAddresses = new TreeSet<String>(); + SortedSet<String> orAddresses = new TreeSet<>(); if (this.address != null) { orAddresses.add(this.address); } @@ -193,11 +193,9 @@ public class NodeStatus extends Document { return this.dirPort; }
- private static Map<String, Integer> relayFlagIndexes = - new HashMap<String, Integer>(); + private static Map<String, Integer> relayFlagIndexes = new HashMap<>();
- private static Map<Integer, String> relayFlagStrings = - new HashMap<Integer, String>(); + private static Map<Integer, String> relayFlagStrings = new HashMap<>();
private BitSet relayFlags;
@@ -226,7 +224,7 @@ public class NodeStatus extends Document {
@SuppressWarnings("checkstyle:javadocmethod") public SortedSet<String> getRelayFlags() { - SortedSet<String> result = new TreeSet<String>(); + SortedSet<String> result = new TreeSet<>(); if (this.relayFlags != null) { for (int i = this.relayFlags.nextSetBit(0); i >= 0; i = this.relayFlags.nextSetBit(i + 1)) { @@ -267,10 +265,10 @@ public class NodeStatus extends Document { }
private SortedMap<Long, Set<String>> lastAddresses = - new TreeMap<Long, Set<String>>(Collections.reverseOrder()); + new TreeMap<>(Collections.reverseOrder());
public SortedMap<Long, Set<String>> getLastAddresses() { - return new TreeMap<Long, Set<String>>(this.lastAddresses); + return new TreeMap<>(this.lastAddresses); }
/** Adds addresses and ports together with the time in milliseconds @@ -278,7 +276,7 @@ public class NodeStatus extends Document { * addresses and ports. */ public void addLastAddresses(long lastSeenMillis, String address, int orPort, int dirPort, SortedSet<String> orAddressesAndPorts) { - Set<String> addressesAndPorts = new HashSet<String>(); + Set<String> addressesAndPorts = new HashSet<>(); addressesAndPorts.add(address + ":" + orPort); if (dirPort > 0) { addressesAndPorts.add(address + ":" + dirPort); @@ -332,7 +330,7 @@ public class NodeStatus extends Document { }
public SortedSet<String> getExitAddresses() { - return new TreeSet<String>(this.exitAddresses); + return new TreeSet<>(this.exitAddresses); }
/* GeoIP lookup results: */ @@ -396,7 +394,7 @@ public class NodeStatus extends Document { * declared family that are not in a mutual family relationship with * this relay. */ public SortedSet<String> getAllegedFamily() { - SortedSet<String> allegedFamily = new TreeSet<String>( + SortedSet<String> allegedFamily = new TreeSet<>( stringArrayToSortedSet(this.declaredFamily)); allegedFamily.removeAll(stringArrayToSortedSet(this.effectiveFamily)); return allegedFamily; @@ -406,7 +404,7 @@ public class NodeStatus extends Document { * reached via mutual family relationships except for those that can be * reached directly via such a relationship. */ public SortedSet<String> getIndirectFamily() { - SortedSet<String> indirectFamily = new TreeSet<String>( + SortedSet<String> indirectFamily = new TreeSet<>( stringArrayToSortedSet(this.extendedFamily)); indirectFamily.removeAll(stringArrayToSortedSet(this.effectiveFamily)); return indirectFamily; @@ -433,8 +431,8 @@ public class NodeStatus extends Document { NodeStatus nodeStatus = new NodeStatus(fingerprint); nodeStatus.setRelay(parts[0].equals("r")); nodeStatus.setNickname(parts[1]); - SortedSet<String> orAddressesAndPorts = new TreeSet<String>(); - SortedSet<String> exitAddresses = new TreeSet<String>(); + SortedSet<String> orAddressesAndPorts = new TreeSet<>(); + SortedSet<String> exitAddresses = new TreeSet<>(); String addresses = parts[3]; String address = null; if (addresses.contains(";")) { @@ -471,7 +469,7 @@ public class NodeStatus extends Document { int dirPort = Integer.parseInt(parts[7]); nodeStatus.setOrPort(orPort); nodeStatus.setDirPort(dirPort); - nodeStatus.setRelayFlags(new TreeSet<String>( + nodeStatus.setRelayFlags(new TreeSet<>( Arrays.asList(parts[8].split(",")))); nodeStatus.setConsensusWeight(Long.parseLong(parts[9])); nodeStatus.setCountryCode(parts[10]); @@ -523,9 +521,9 @@ public class NodeStatus extends Document { * 2. indirect members that can be reached via others only. * Each group contains zero or more ';'-separated fingerprints. */ String[] groups = parts[22].split(":", -1); - SortedSet<String> allegedFamily = new TreeSet<String>(); - SortedSet<String> effectiveFamily = new TreeSet<String>(); - SortedSet<String> indirectFamily = new TreeSet<String>(); + SortedSet<String> allegedFamily = new TreeSet<>(); + SortedSet<String> effectiveFamily = new TreeSet<>(); + SortedSet<String> indirectFamily = new TreeSet<>(); if (groups[0].length() > 0) { allegedFamily.addAll(Arrays.asList(groups[0].split(";"))); } @@ -535,12 +533,12 @@ public class NodeStatus extends Document { if (groups.length > 2 && groups[2].length() > 0) { indirectFamily.addAll(Arrays.asList(groups[2].split(";"))); } - SortedSet<String> declaredFamily = new TreeSet<String>(); + SortedSet<String> declaredFamily = new TreeSet<>(); declaredFamily.addAll(allegedFamily); declaredFamily.addAll(effectiveFamily); nodeStatus.setDeclaredFamily(declaredFamily); nodeStatus.setEffectiveFamily(effectiveFamily); - SortedSet<String> extendedFamily = new TreeSet<String>(); + SortedSet<String> extendedFamily = new TreeSet<>(); extendedFamily.addAll(effectiveFamily); extendedFamily.addAll(indirectFamily); nodeStatus.setExtendedFamily(extendedFamily); diff --git a/src/main/java/org/torproject/onionoo/docs/SummaryDocument.java b/src/main/java/org/torproject/onionoo/docs/SummaryDocument.java index b7f62ad..3ca4960 100644 --- a/src/main/java/org/torproject/onionoo/docs/SummaryDocument.java +++ b/src/main/java/org/torproject/onionoo/docs/SummaryDocument.java @@ -145,7 +145,7 @@ public class SummaryDocument extends Document { private List<String> stringArrayToList(String[] stringArray) { List<String> list; if (stringArray == null) { - list = new ArrayList<String>(); + list = new ArrayList<>(); } else { list = Arrays.asList(stringArray); } @@ -153,7 +153,7 @@ public class SummaryDocument extends Document { }
private SortedSet<String> stringArrayToSortedSet(String[] stringArray) { - SortedSet<String> sortedSet = new TreeSet<String>(); + SortedSet<String> sortedSet = new TreeSet<>(); if (stringArray != null) { sortedSet.addAll(Arrays.asList(stringArray)); } diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java index bcf0c6e..7c78f54 100644 --- a/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java +++ b/src/main/java/org/torproject/onionoo/docs/UptimeHistory.java @@ -83,7 +83,7 @@ public class UptimeHistory implements Comparable<UptimeHistory> { } SortedSet<String> flags = null; if (parts[0].equals("R")) { - flags = new TreeSet<String>(); + flags = new TreeSet<>(); for (int i = 3; i < parts.length; i++) { flags.add(parts[i]); } diff --git a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java index 286b32f..18cd259 100644 --- a/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/UptimeStatus.java @@ -26,15 +26,13 @@ public class UptimeStatus extends Document { this.isDirty = false; }
- private SortedSet<UptimeHistory> relayHistory = - new TreeSet<UptimeHistory>(); + private SortedSet<UptimeHistory> relayHistory = new TreeSet<>();
public SortedSet<UptimeHistory> getRelayHistory() { return this.relayHistory; }
- private SortedSet<UptimeHistory> bridgeHistory = - new TreeSet<UptimeHistory>(); + private SortedSet<UptimeHistory> bridgeHistory = new TreeSet<>();
public SortedSet<UptimeHistory> getBridgeHistory() { return this.bridgeHistory; @@ -69,7 +67,7 @@ public class UptimeStatus extends Document { UptimeHistory interval = new UptimeHistory(relay, startMillis, 1, flags); NavigableSet<UptimeHistory> existingIntervals = - new TreeSet<UptimeHistory>(history.headSet(new UptimeHistory( + new TreeSet<>(history.headSet(new UptimeHistory( relay, startMillis + DateTimeHelper.ONE_HOUR, 0, flags))); for (UptimeHistory prev : existingIntervals.descendingSet()) { if (prev.isRelay() != interval.isRelay() @@ -116,8 +114,7 @@ public class UptimeStatus extends Document { }
private void compressHistory(SortedSet<UptimeHistory> history) { - SortedSet<UptimeHistory> uncompressedHistory = - new TreeSet<UptimeHistory>(history); + SortedSet<UptimeHistory> uncompressedHistory = new TreeSet<>(history); history.clear(); UptimeHistory lastInterval = null; for (UptimeHistory interval : uncompressedHistory) { diff --git a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java index 5c18dee..3257283 100644 --- a/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/WeightsStatus.java @@ -40,8 +40,7 @@ public class WeightsStatus extends Document { } };
- private SortedMap<long[], double[]> history = - new TreeMap<long[], double[]>(histComparator); + private SortedMap<long[], double[]> history = new TreeMap<>(histComparator);
public void setHistory(SortedMap<long[], double[]> history) { this.history = history; diff --git a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java index 3e8697e..e9c8667 100644 --- a/src/main/java/org/torproject/onionoo/server/MostFrequentString.java +++ b/src/main/java/org/torproject/onionoo/server/MostFrequentString.java @@ -14,7 +14,7 @@ import java.util.TreeSet;
class MostFrequentString {
- Map<String, Integer> stringFrequencies = new HashMap<String, Integer>(); + Map<String, Integer> stringFrequencies = new HashMap<>();
void addString(String string) { if (!this.stringFrequencies.containsKey(string)) { @@ -27,15 +27,14 @@ class MostFrequentString {
@Override public String toString() { - SortedMap<Integer, SortedSet<String>> sortedFrequencies = - new TreeMap<Integer, SortedSet<String>>( + SortedMap<Integer, SortedSet<String>> sortedFrequencies = new TreeMap<>( Collections.reverseOrder()); if (this.stringFrequencies.isEmpty()) { return "null (0)"; } for (Map.Entry<String, Integer> e : stringFrequencies.entrySet()) { if (!sortedFrequencies.containsKey(e.getValue())) { - sortedFrequencies.put(e.getValue(), new TreeSet<String>( + sortedFrequencies.put(e.getValue(), new TreeSet<>( Arrays.asList(new String[] { e.getKey() } ))); } else { sortedFrequencies.get(e.getValue()).add(e.getKey()); diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java index b470323..1229e6b 100644 --- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java +++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java @@ -144,31 +144,21 @@ public class NodeIndexer implements ServletContextListener, Runnable { } documentStore.invalidateDocumentCache(); Map<String, SummaryDocument> newRelayFingerprintSummaryLines = - new HashMap<String, SummaryDocument>(); + new HashMap<>(); Map<String, SummaryDocument> newBridgeFingerprintSummaryLines = - new HashMap<String, SummaryDocument>(); - Map<String, Set<String>> newRelaysByCountryCode = - new HashMap<String, Set<String>>(); - Map<String, Set<String>> newRelaysByAsNumber = - new HashMap<String, Set<String>>(); - Map<String, Set<String>> newRelaysByFlag = - new HashMap<String, Set<String>>(); - Map<String, Set<String>> newBridgesByFlag = - new HashMap<String, Set<String>>(); - Map<String, Set<String>> newRelaysByContact = - new HashMap<String, Set<String>>(); - Map<String, Set<String>> newRelaysByFamily = - new HashMap<String, Set<String>>(); - SortedMap<Integer, Set<String>> newRelaysByFirstSeenDays = - new TreeMap<Integer, Set<String>>(); - SortedMap<Integer, Set<String>> newBridgesByFirstSeenDays = - new TreeMap<Integer, Set<String>>(); - SortedMap<Integer, Set<String>> newRelaysByLastSeenDays = - new TreeMap<Integer, Set<String>>(); - SortedMap<Integer, Set<String>> newBridgesByLastSeenDays = - new TreeMap<Integer, Set<String>>(); - Set<SummaryDocument> currentRelays = new HashSet<SummaryDocument>(); - Set<SummaryDocument> currentBridges = new HashSet<SummaryDocument>(); + new HashMap<>(); + Map<String, Set<String>> newRelaysByCountryCode = new HashMap<>(); + Map<String, Set<String>> newRelaysByAsNumber = new HashMap<>(); + Map<String, Set<String>> newRelaysByFlag = new HashMap<>(); + Map<String, Set<String>> newBridgesByFlag = new HashMap<>(); + Map<String, Set<String>> newRelaysByContact = new HashMap<>(); + Map<String, Set<String>> newRelaysByFamily = new HashMap<>(); + SortedMap<Integer, Set<String>> newRelaysByFirstSeenDays = new TreeMap<>(); + SortedMap<Integer, Set<String>> newBridgesByFirstSeenDays = new TreeMap<>(); + SortedMap<Integer, Set<String>> newRelaysByLastSeenDays = new TreeMap<>(); + SortedMap<Integer, Set<String>> newBridgesByLastSeenDays = new TreeMap<>(); + Set<SummaryDocument> currentRelays = new HashSet<>(); + Set<SummaryDocument> currentBridges = new HashSet<>(); SortedSet<String> fingerprints = documentStore.list( SummaryDocument.class); long relaysLastValidAfterMillis = 0L; @@ -191,8 +181,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { /* This variable can go away once all Onionoo services had their * hourly updater write effective families to summary documents at * least once. Remove this code after September 8, 2015. */ - SortedMap<String, Set<String>> computedEffectiveFamilies = - new TreeMap<String, Set<String>>(); + SortedMap<String, Set<String>> computedEffectiveFamilies = new TreeMap<>(); for (SummaryDocument entry : currentRelays) { String fingerprint = entry.getFingerprint().toUpperCase(); String hashedFingerprint = entry.getHashedFingerprint() @@ -276,7 +265,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { for (Map.Entry<String, Set<String>> e : computedEffectiveFamilies.entrySet()) { String fingerprint = e.getKey(); - Set<String> inMutualFamilyRelation = new HashSet<String>(); + Set<String> inMutualFamilyRelation = new HashSet<>(); for (String otherFingerprint : e.getValue()) { if (computedEffectiveFamilies.containsKey(otherFingerprint) && computedEffectiveFamilies.get(otherFingerprint).contains( diff --git a/src/main/java/org/torproject/onionoo/server/RequestHandler.java b/src/main/java/org/torproject/onionoo/server/RequestHandler.java index 32af238..c94edd4 100644 --- a/src/main/java/org/torproject/onionoo/server/RequestHandler.java +++ b/src/main/java/org/torproject/onionoo/server/RequestHandler.java @@ -133,11 +133,9 @@ public class RequestHandler { this.family = family; }
- private Map<String, SummaryDocument> filteredRelays = - new HashMap<String, SummaryDocument>(); + private Map<String, SummaryDocument> filteredRelays = new HashMap<>();
- private Map<String, SummaryDocument> filteredBridges = - new HashMap<String, SummaryDocument>(); + private Map<String, SummaryDocument> filteredBridges = new HashMap<>();
/** Handles this request by filtering by all given parameters and then * possibly ordering, offsetting, and limiting results. */ @@ -190,7 +188,7 @@ public class RequestHandler { return; } boolean runningRequested = this.running.equals("true"); - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (Map.Entry<String, SummaryDocument> e : filteredRelays.entrySet()) { if (e.getValue().isRunning() != runningRequested) { @@ -200,7 +198,7 @@ public class RequestHandler { for (String fingerprint : removeRelays) { this.filteredRelays.remove(fingerprint); } - Set<String> removeBridges = new HashSet<String>(); + Set<String> removeBridges = new HashSet<>(); for (Map.Entry<String, SummaryDocument> e : filteredBridges.entrySet()) { if (e.getValue().isRunning() != runningRequested) { @@ -223,7 +221,7 @@ public class RequestHandler { }
private void filterBySearchTerm(String searchTerm) { - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (Map.Entry<String, SummaryDocument> e : filteredRelays.entrySet()) { String fingerprint = e.getKey(); @@ -276,7 +274,7 @@ public class RequestHandler { for (String fingerprint : removeRelays) { this.filteredRelays.remove(fingerprint); } - Set<String> removeBridges = new HashSet<String>(); + Set<String> removeBridges = new HashSet<>(); for (Map.Entry<String, SummaryDocument> e : filteredBridges.entrySet()) { String hashedFingerprint = e.getKey(); @@ -356,7 +354,7 @@ public class RequestHandler { } else { Set<String> relaysWithCountryCode = this.nodeIndex.getRelaysByCountryCode().get(countryCode); - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (String fingerprint : this.filteredRelays.keySet()) { if (!relaysWithCountryCode.contains(fingerprint)) { removeRelays.add(fingerprint); @@ -383,7 +381,7 @@ public class RequestHandler { } else { Set<String> relaysWithAsNumber = this.nodeIndex.getRelaysByAsNumber().get(asNumber); - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (String fingerprint : this.filteredRelays.keySet()) { if (!relaysWithAsNumber.contains(fingerprint)) { removeRelays.add(fingerprint); @@ -407,7 +405,7 @@ public class RequestHandler { } else { Set<String> relaysWithFlag = this.nodeIndex.getRelaysByFlag().get( flag); - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (String fingerprint : this.filteredRelays.keySet()) { if (!relaysWithFlag.contains(fingerprint)) { removeRelays.add(fingerprint); @@ -422,7 +420,7 @@ public class RequestHandler { } else { Set<String> bridgesWithFlag = this.nodeIndex.getBridgesByFlag().get( flag); - Set<String> removeBridges = new HashSet<String>(); + Set<String> removeBridges = new HashSet<>(); for (String fingerprint : this.filteredBridges.keySet()) { if (!bridgesWithFlag.contains(fingerprint)) { removeBridges.add(fingerprint); @@ -459,7 +457,7 @@ public class RequestHandler { private void filterNodesByDays( Map<String, SummaryDocument> filteredNodes, SortedMap<Integer, Set<String>> nodesByDays, int[] days) { - Set<String> removeNodes = new HashSet<String>(); + Set<String> removeNodes = new HashSet<>(); for (Set<String> nodes : nodesByDays.headMap(days[0]).values()) { removeNodes.addAll(nodes); } @@ -479,7 +477,7 @@ public class RequestHandler { /* Not filtering by contact information. */ return; } - Set<String> removeRelays = new HashSet<String>(); + Set<String> removeRelays = new HashSet<>(); for (Map.Entry<String, Set<String>> e : this.nodeIndex.getRelaysByContact().entrySet()) { String contact = e.getKey(); @@ -502,8 +500,7 @@ public class RequestHandler { /* Not filtering by relay family. */ return; } - Set<String> removeRelays = new HashSet<String>( - this.filteredRelays.keySet()); + Set<String> removeRelays = new HashSet<>(this.filteredRelays.keySet()); removeRelays.remove(this.family); if (this.nodeIndex.getRelaysByFamily().containsKey(this.family)) { removeRelays.removeAll(this.nodeIndex.getRelaysByFamily() @@ -580,15 +577,13 @@ public class RequestHandler { } }
- private List<SummaryDocument> orderedRelays = - new ArrayList<SummaryDocument>(); + private List<SummaryDocument> orderedRelays = new ArrayList<>();
public List<SummaryDocument> getOrderedRelays() { return this.orderedRelays; }
- private List<SummaryDocument> orderedBridges = - new ArrayList<SummaryDocument>(); + private List<SummaryDocument> orderedBridges = new ArrayList<>();
public List<SummaryDocument> getOrderedBridges() { return this.orderedBridges; diff --git a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java index 0e4c68f..45a52a2 100644 --- a/src/main/java/org/torproject/onionoo/server/ResourceServlet.java +++ b/src/main/java/org/torproject/onionoo/server/ResourceServlet.java @@ -66,13 +66,13 @@ public class ResourceServlet extends HttpServlet {
private static final long CACHE_INTERVAL = 5L * 60L * 1000L;
- private static Set<String> knownParameters = new HashSet<String>( + private static Set<String> knownParameters = new HashSet<>( Arrays.asList(("type,running,search,lookup,fingerprint,country,as," + "flag,first_seen_days,last_seen_days,contact,order,limit," + "offset,fields,family").split(",")));
private static Set<String> illegalSearchQualifiers = - new HashSet<String>(Arrays.asList(("search,fingerprint,order,limit," + new HashSet<>(Arrays.asList(("search,fingerprint,order,limit," + "offset,fields").split(",")));
/** Handles the HTTP GET request in the wrapped <code>request</code> by @@ -124,7 +124,7 @@ public class ResourceServlet extends HttpServlet {
/* Extract parameters either from the old-style URI or from request * parameters. */ - Map<String, String> parameterMap = new HashMap<String, String>(); + Map<String, String> parameterMap = new HashMap<>(); for (Object parameterKey : request.getParameterMap().keySet()) { String[] parameterValues = request.getParameterValues((String) parameterKey); @@ -148,7 +148,7 @@ public class ResourceServlet extends HttpServlet { response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } - List<String> unqualifiedSearchTerms = new ArrayList<String>(); + List<String> unqualifiedSearchTerms = new ArrayList<>(); for (String searchTerm : searchTerms) { if (searchTerm.contains(":") && !searchTerm.startsWith("[")) { String[] parts = searchTerm.split(":", 2); diff --git a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java index 4c13334..bb532f6 100644 --- a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java +++ b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java @@ -47,15 +47,13 @@ public class ResponseBuilder { this.bridgesPublishedString = bridgesPublishedString; }
- private List<SummaryDocument> orderedRelays = - new ArrayList<SummaryDocument>(); + private List<SummaryDocument> orderedRelays = new ArrayList<>();
public void setOrderedRelays(List<SummaryDocument> orderedRelays) { this.orderedRelays = orderedRelays; }
- private List<SummaryDocument> orderedBridges = - new ArrayList<SummaryDocument>(); + private List<SummaryDocument> orderedBridges = new ArrayList<>();
public void setOrderedBridges(List<SummaryDocument> orderedBridges) { this.orderedBridges = orderedBridges; diff --git a/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java index 20971f8..44c4e1b 100644 --- a/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java @@ -66,7 +66,7 @@ public class ClientsStatusUpdater implements DescriptorListener, }
private SortedMap<String, SortedSet<ClientsHistory>> newResponses = - new TreeMap<String, SortedSet<ClientsHistory>>(); + new TreeMap<>();
private void processBridgeExtraInfoDescriptor( ExtraInfoDescriptor descriptor) { @@ -125,8 +125,7 @@ public class ClientsStatusUpdater implements DescriptorListener, private SortedMap<String, Double> weightResponsesWithUniqueIps( double totalResponses, SortedMap<String, Integer> uniqueIps, String omitString) { - SortedMap<String, Double> weightedResponses = - new TreeMap<String, Double>(); + SortedMap<String, Double> weightedResponses = new TreeMap<>(); int totalUniqueIps = 0; if (uniqueIps != null) { for (Map.Entry<String, Integer> e : uniqueIps.entrySet()) { diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java b/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java index d51bc20..1e41f25 100644 --- a/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java +++ b/src/main/java/org/torproject/onionoo/updater/DescriptorDownloader.java @@ -61,7 +61,7 @@ class DescriptorDownloader { } }
- private SortedSet<String> localFiles = new TreeSet<String>(); + private SortedSet<String> localFiles = new TreeSet<>();
public int statLocalFiles() { File localDirectory = new File(this.inDir, this.directory); @@ -73,7 +73,7 @@ class DescriptorDownloader { return this.localFiles.size(); }
- private SortedSet<String> remoteFiles = new TreeSet<String>(); + private SortedSet<String> remoteFiles = new TreeSet<>();
public int fetchRemoteDirectory() { String directoryUrl = this.protocolHostNameResourcePrefix diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java index 27a046e..5ce8cfa 100644 --- a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java +++ b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java @@ -156,7 +156,7 @@ class DescriptorQueue { } this.historyFile = new File(this.statusDir, historyFileName); if (this.historyFile.exists() && this.historyFile.isFile()) { - SortedMap<String, Long> excludedFiles = new TreeMap<String, Long>(); + SortedMap<String, Long> excludedFiles = new TreeMap<>(); try (BufferedReader br = new BufferedReader(new FileReader( this.historyFile))) { String line; @@ -184,8 +184,7 @@ class DescriptorQueue { if (this.historyFile == null) { return; } - SortedMap<String, Long> excludedAndParsedFiles = - new TreeMap<String, Long>(); + SortedMap<String, Long> excludedAndParsedFiles = new TreeMap<>(); excludedAndParsedFiles.putAll( this.descriptorReader.getExcludedFiles()); excludedAndParsedFiles.putAll(this.descriptorReader.getParsedFiles()); diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java index 79fe53b..33c8a8e 100644 --- a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java +++ b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java @@ -34,9 +34,8 @@ public class DescriptorSource {
/** Instantiates a new descriptor source. */ public DescriptorSource() { - this.descriptorQueues = new ArrayList<DescriptorQueue>(); - this.descriptorListeners = - new HashMap<DescriptorType, Set<DescriptorListener>>(); + this.descriptorQueues = new ArrayList<>(); + this.descriptorListeners = new HashMap<>(); }
private DescriptorQueue getDescriptorQueue( diff --git a/src/main/java/org/torproject/onionoo/updater/LookupService.java b/src/main/java/org/torproject/onionoo/updater/LookupService.java index fcef0bc..fb9bf4a 100644 --- a/src/main/java/org/torproject/onionoo/updater/LookupService.java +++ b/src/main/java/org/torproject/onionoo/updater/LookupService.java @@ -104,15 +104,14 @@ public class LookupService { public SortedMap<String, LookupResult> lookup( SortedSet<String> addressStrings) {
- SortedMap<String, LookupResult> lookupResults = - new TreeMap<String, LookupResult>(); + SortedMap<String, LookupResult> lookupResults = new TreeMap<>();
if (!this.hasAllFiles) { return lookupResults; }
/* Obtain a map from relay IP address strings to numbers. */ - Map<String, Long> addressStringNumbers = new HashMap<String, Long>(); + Map<String, Long> addressStringNumbers = new HashMap<>(); for (String addressString : addressStrings) { long addressNumber = this.parseAddressString(addressString); if (addressNumber >= 0L) { @@ -125,12 +124,11 @@ public class LookupService {
/* Obtain a map from IP address numbers to blocks and to latitudes and longitudes. */ - Map<Long, Long> addressNumberBlocks = new HashMap<Long, Long>(); - Map<Long, Float[]> addressNumberLatLong = - new HashMap<Long, Float[]>(); + Map<Long, Long> addressNumberBlocks = new HashMap<>(); + Map<Long, Float[]> addressNumberLatLong = new HashMap<>(); try (BufferedReader br = this.createBufferedReaderFromUtf8File( this.geoLite2CityBlocksIPv4CsvFile)) { - SortedSet<Long> sortedAddressNumbers = new TreeSet<Long>( + SortedSet<Long> sortedAddressNumbers = new TreeSet<>( addressStringNumbers.values()); String line = br.readLine(); while ((line = br.readLine()) != null) { @@ -193,11 +191,10 @@ public class LookupService { }
/* Obtain a map from relevant blocks to location lines. */ - Map<Long, String> blockLocations = new HashMap<Long, String>(); + Map<Long, String> blockLocations = new HashMap<>(); try (BufferedReader br = this.createBufferedReaderFromUtf8File( this.geoLite2CityLocationsEnCsvFile)) { - Set<Long> blockNumbers = new HashSet<Long>( - addressNumberBlocks.values()); + Set<Long> blockNumbers = new HashSet<>(addressNumberBlocks.values()); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] parts = line.replaceAll(""", "").split(",", 13); @@ -229,10 +226,10 @@ public class LookupService { }
/* Obtain a map from IP address numbers to ASN. */ - Map<Long, String> addressNumberAsn = new HashMap<Long, String>(); + Map<Long, String> addressNumberAsn = new HashMap<>(); try (BufferedReader br = this.createBufferedReaderFromIso88591File( this.geoIpAsNum2CsvFile)) { - SortedSet<Long> sortedAddressNumbers = new TreeSet<Long>( + SortedSet<Long> sortedAddressNumbers = new TreeSet<>( addressStringNumbers.values()); long firstAddressNumber = sortedAddressNumbers.first(); String line; diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java index 202524d..b6dcdf7 100644 --- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java @@ -82,8 +82,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
private long now;
- private SortedMap<String, NodeStatus> knownNodes = - new TreeMap<String, NodeStatus>(); + private SortedMap<String, NodeStatus> knownNodes = new TreeMap<>();
private long relaysLastValidAfterMillis = -1L;
@@ -145,8 +144,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, } }
- private Map<String, SortedSet<String>> declaredFamilies = - new HashMap<String, SortedSet<String>>(); + private Map<String, SortedSet<String>> declaredFamilies = new HashMap<>();
private void processRelayServerDescriptor( ServerDescriptor descriptor) { @@ -178,7 +176,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, detailsStatus.setContact(descriptor.getContact()); detailsStatus.setPlatform(descriptor.getPlatform()); if (descriptor.getFamilyEntries() != null) { - SortedSet<String> declaredFamily = new TreeSet<String>(); + SortedSet<String> declaredFamily = new TreeSet<>(); for (String familyMember : descriptor.getFamilyEntries()) { if (familyMember.startsWith("$") && familyMember.length() >= 41) { declaredFamily.add( @@ -193,8 +191,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, && (descriptor.getIpv6DefaultPolicy().equals("accept") || descriptor.getIpv6DefaultPolicy().equals("reject")) && descriptor.getIpv6PortList() != null) { - Map<String, List<String>> exitPolicyV6Summary = - new HashMap<String, List<String>>(); + Map<String, List<String>> exitPolicyV6Summary = new HashMap<>(); List<String> portsOrPortRanges = Arrays.asList( descriptor.getIpv6PortList().split(",")); exitPolicyV6Summary.put(descriptor.getIpv6DefaultPolicy(), @@ -206,8 +203,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, this.documentStore.store(detailsStatus, fingerprint); }
- private Map<String, Map<String, Long>> exitListEntries = - new HashMap<String, Map<String, Long>>(); + private Map<String, Map<String, Long>> exitListEntries = new HashMap<>();
private void processExitList(ExitList exitList) { for (ExitList.Entry exitListEntry : exitList.getEntries()) { @@ -219,8 +215,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, continue; } if (!this.exitListEntries.containsKey(fingerprint)) { - this.exitListEntries.put(fingerprint, - new HashMap<String, Long>()); + this.exitListEntries.put(fingerprint, new HashMap<String, Long>()); } String exitAddress = exitAddressScanMillis.getKey(); if (!this.exitListEntries.get(fingerprint).containsKey( @@ -234,11 +229,9 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, } }
- private Map<String, Long> lastSeenUnmeasured = - new HashMap<String, Long>(); + private Map<String, Long> lastSeenUnmeasured = new HashMap<>();
- private Map<String, Long> lastSeenMeasured = - new HashMap<String, Long>(); + private Map<String, Long> lastSeenMeasured = new HashMap<>();
private void processRelayNetworkStatusConsensus( RelayNetworkStatusConsensus consensus) { @@ -248,7 +241,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, } Set<String> recommendedVersions = null; if (consensus.getRecommendedServerVersions() != null) { - recommendedVersions = new HashSet<String>(); + recommendedVersions = new HashSet<>(); for (String recommendedVersion : consensus.getRecommendedServerVersions()) { recommendedVersions.add("Tor " + recommendedVersion); @@ -266,7 +259,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, String address = entry.getAddress(); int orPort = entry.getOrPort(); int dirPort = entry.getDirPort(); - SortedSet<String> orAddressesAndPorts = new TreeSet<String>( + SortedSet<String> orAddressesAndPorts = new TreeSet<>( entry.getOrAddresses()); nodeStatus.addLastAddresses(validAfterMillis, address, orPort, dirPort, orAddressesAndPorts); @@ -374,7 +367,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, nodeStatus.setRelay(false); nodeStatus.setNickname(entry.getNickname()); nodeStatus.setAddress(entry.getAddress()); - nodeStatus.setOrAddressesAndPorts(new TreeSet<String>( + nodeStatus.setOrAddressesAndPorts(new TreeSet<>( entry.getOrAddresses())); nodeStatus.setOrPort(entry.getOrPort()); nodeStatus.setDirPort(entry.getDirPort()); @@ -405,9 +398,9 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
/* Step 2: read node statuses from disk. */
- private SortedSet<String> currentRelays = new TreeSet<String>(); + private SortedSet<String> currentRelays = new TreeSet<>();
- private SortedSet<String> runningRelays = new TreeSet<String>(); + private SortedSet<String> runningRelays = new TreeSet<>();
private void readNodeStatuses() { SortedSet<String> previouslyKnownNodes = this.documentStore.list( @@ -534,8 +527,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, * probabilities. */
private void startReverseDomainNameLookups() { - Map<String, Long> addressLastLookupTimes = - new HashMap<String, Long>(); + Map<String, Long> addressLastLookupTimes = new HashMap<>(); for (String fingerprint : this.currentRelays) { NodeStatus nodeStatus = this.knownNodes.get(fingerprint); addressLastLookupTimes.put(nodeStatus.getAddress(), @@ -545,11 +537,10 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, this.reverseDomainNameResolver.startReverseDomainNameLookups(); }
- private SortedMap<String, LookupResult> geoIpLookupResults = - new TreeMap<String, LookupResult>(); + private SortedMap<String, LookupResult> geoIpLookupResults = new TreeMap<>();
private void lookUpCitiesAndASes() { - SortedSet<String> addressStrings = new TreeSet<String>(); + SortedSet<String> addressStrings = new TreeSet<>(); for (String fingerprint : this.currentRelays) { NodeStatus nodeStatus = this.knownNodes.get(fingerprint); addressStrings.add(nodeStatus.getAddress()); @@ -571,17 +562,13 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, } }
- private SortedMap<String, Float> consensusWeightFractions = - new TreeMap<String, Float>(); + private SortedMap<String, Float> consensusWeightFractions = new TreeMap<>();
- private SortedMap<String, Float> guardProbabilities = - new TreeMap<String, Float>(); + private SortedMap<String, Float> guardProbabilities = new TreeMap<>();
- private SortedMap<String, Float> middleProbabilities = - new TreeMap<String, Float>(); + private SortedMap<String, Float> middleProbabilities = new TreeMap<>();
- private SortedMap<String, Float> exitProbabilities = - new TreeMap<String, Float>(); + private SortedMap<String, Float> exitProbabilities = new TreeMap<>();
private void calculatePathSelectionProbabilities() { boolean consensusContainsBandwidthWeights = false; @@ -594,7 +581,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, double wee = 0.0; double wed = 0.0; if (this.lastBandwidthWeights != null) { - SortedSet<String> weightKeys = new TreeSet<String>(Arrays.asList( + SortedSet<String> weightKeys = new TreeSet<>(Arrays.asList( "Wgg,Wgd,Wmg,Wmm,Wme,Wmd,Wee,Wed".split(","))); weightKeys.removeAll(this.lastBandwidthWeights.keySet()); if (weightKeys.isEmpty()) { @@ -615,14 +602,10 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, + "this execution."); return; } - SortedMap<String, Double> consensusWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> guardWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> middleWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> exitWeights = - new TreeMap<String, Double>(); + SortedMap<String, Double> consensusWeights = new TreeMap<>(); + SortedMap<String, Double> guardWeights = new TreeMap<>(); + SortedMap<String, Double> middleWeights = new TreeMap<>(); + SortedMap<String, Double> exitWeights = new TreeMap<>(); double totalConsensusWeight = 0.0; double totalGuardWeight = 0.0; double totalMiddleWeight = 0.0; @@ -685,8 +668,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, }
private void computeEffectiveAndExtendedFamilies() { - SortedMap<String, SortedSet<String>> declaredFamilies = - new TreeMap<String, SortedSet<String>>(); + SortedMap<String, SortedSet<String>> declaredFamilies = new TreeMap<>(); for (String fingerprint : this.currentRelays) { NodeStatus nodeStatus = this.knownNodes.get(fingerprint); if (nodeStatus != null && nodeStatus.getDeclaredFamily() != null @@ -694,13 +676,12 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, declaredFamilies.put(fingerprint, nodeStatus.getDeclaredFamily()); } } - SortedMap<String, SortedSet<String>> effectiveFamilies = - new TreeMap<String, SortedSet<String>>(); + SortedMap<String, SortedSet<String>> effectiveFamilies = new TreeMap<>(); for (Map.Entry<String, SortedSet<String>> e : declaredFamilies.entrySet()) { String fingerprint = e.getKey(); SortedSet<String> declaredFamily = e.getValue(); - SortedSet<String> effectiveFamily = new TreeSet<String>(); + SortedSet<String> effectiveFamily = new TreeSet<>(); for (String declaredFamilyMember : declaredFamily) { if (declaredFamilies.containsKey(declaredFamilyMember) && declaredFamilies.get(declaredFamilyMember).contains( @@ -712,16 +693,15 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, effectiveFamilies.put(fingerprint, effectiveFamily); } } - SortedMap<String, SortedSet<String>> extendedFamilies = - new TreeMap<String, SortedSet<String>>(); - SortedSet<String> visited = new TreeSet<String>(); + SortedMap<String, SortedSet<String>> extendedFamilies = new TreeMap<>(); + SortedSet<String> visited = new TreeSet<>(); for (String fingerprint : effectiveFamilies.keySet()) { if (visited.contains(fingerprint)) { continue; } - SortedSet<String> toVisit = new TreeSet<String>(); + SortedSet<String> toVisit = new TreeSet<>(); toVisit.add(fingerprint); - SortedSet<String> extendedFamily = new TreeSet<String>(); + SortedSet<String> extendedFamily = new TreeSet<>(); while (!toVisit.isEmpty()) { String visiting = toVisit.first(); toVisit.remove(visiting); @@ -739,7 +719,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, if (extendedFamily.size() > 1) { for (String member : extendedFamily) { SortedSet<String> extendedFamilyWithoutMember = - new TreeSet<String>(extendedFamily); + new TreeSet<>(extendedFamily); extendedFamilyWithoutMember.remove(member); extendedFamilies.put(member, extendedFamilyWithoutMember); } @@ -763,8 +743,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
private long startedRdnsLookups = -1L;
- private SortedMap<String, String> rdnsLookupResults = - new TreeMap<String, String>(); + private SortedMap<String, String> rdnsLookupResults = new TreeMap<>();
private void finishReverseDomainNameLookups() { this.reverseDomainNameResolver.finishReverseDomainNameLookups(); @@ -795,7 +774,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.setContact(detailsStatus.getContact());
- Map<String, Long> exitAddresses = new HashMap<String, Long>(); + Map<String, Long> exitAddresses = new HashMap<>(); if (detailsStatus.getExitAddresses() != null) { for (Map.Entry<String, Long> e : detailsStatus.getExitAddresses().entrySet()) { @@ -817,7 +796,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener, } detailsStatus.setExitAddresses(exitAddresses); SortedSet<String> exitAddressesWithoutOrAddresses = - new TreeSet<String>(exitAddresses.keySet()); + new TreeSet<>(exitAddresses.keySet()); exitAddressesWithoutOrAddresses.removeAll( nodeStatus.getOrAddresses()); nodeStatus.setExitAddresses(exitAddressesWithoutOrAddresses); diff --git a/src/main/java/org/torproject/onionoo/updater/ReverseDomainNameResolver.java b/src/main/java/org/torproject/onionoo/updater/ReverseDomainNameResolver.java index 3c26975..04222bf 100644 --- a/src/main/java/org/torproject/onionoo/updater/ReverseDomainNameResolver.java +++ b/src/main/java/org/torproject/onionoo/updater/ReverseDomainNameResolver.java @@ -52,7 +52,7 @@ public class ReverseDomainNameResolver { * threads and returns immediately. */ public void startReverseDomainNameLookups() { this.startedRdnsLookups = this.time.currentTimeMillis(); - this.rdnsLookupJobs = new HashSet<String>(); + this.rdnsLookupJobs = new HashSet<>(); for (Map.Entry<String, Long> e : this.addressLastLookupTimes.entrySet()) { if (e.getValue() < this.startedRdnsLookups @@ -60,9 +60,9 @@ public class ReverseDomainNameResolver { this.rdnsLookupJobs.add(e.getKey()); } } - this.rdnsLookupResults = new HashMap<String, String>(); - this.rdnsLookupMillis = new ArrayList<Long>(); - this.rdnsLookupWorkers = new ArrayList<RdnsLookupWorker>(); + this.rdnsLookupResults = new HashMap<>(); + this.rdnsLookupMillis = new ArrayList<>(); + this.rdnsLookupWorkers = new ArrayList<>(); for (int i = 0; i < RDNS_LOOKUP_WORKERS_NUM; i++) { RdnsLookupWorker rdnsLookupWorker = new RdnsLookupWorker(this); this.rdnsLookupWorkers.add(rdnsLookupWorker); @@ -87,7 +87,7 @@ public class ReverseDomainNameResolver { /** Returns reverse domain name lookup results. */ public Map<String, String> getLookupResults() { synchronized (this.rdnsLookupResults) { - return new HashMap<String, String>(this.rdnsLookupResults); + return new HashMap<>(this.rdnsLookupResults); } }
diff --git a/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java index fb8139c..2b5f5fc 100644 --- a/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java @@ -57,11 +57,9 @@ public class UptimeStatusUpdater implements DescriptorListener,
private static class Flags {
- private static Map<String, Integer> flagIndexes = - new HashMap<String, Integer>(); + private static Map<String, Integer> flagIndexes = new HashMap<>();
- private static Map<Integer, String> flagStrings = - new HashMap<Integer, String>(); + private static Map<Integer, String> flagStrings = new HashMap<>();
private BitSet flags;
@@ -77,7 +75,7 @@ public class UptimeStatusUpdater implements DescriptorListener, }
public SortedSet<String> getFlags() { - SortedSet<String> result = new TreeSet<String>(); + SortedSet<String> result = new TreeSet<>(); if (this.flags != null) { for (int i = this.flags.nextSetBit(0); i >= 0; i = this.flags.nextSetBit(i + 1)) { @@ -88,16 +86,15 @@ public class UptimeStatusUpdater implements DescriptorListener, } }
- private SortedMap<Long, Flags> - newRelayStatuses = new TreeMap<Long, Flags>(); + private SortedMap<Long, Flags> newRelayStatuses = new TreeMap<>();
private SortedMap<String, SortedMap<Long, Flags>> - newRunningRelays = new TreeMap<String, SortedMap<Long, Flags>>(); + newRunningRelays = new TreeMap<>();
- private SortedSet<Long> newBridgeStatuses = new TreeSet<Long>(); + private SortedSet<Long> newBridgeStatuses = new TreeSet<>();
private SortedMap<String, SortedSet<Long>> - newRunningBridges = new TreeMap<String, SortedSet<Long>>(); + newRunningBridges = new TreeMap<>();
private void processRelayNetworkStatusConsensus( RelayNetworkStatusConsensus consensus) { @@ -118,7 +115,7 @@ public class UptimeStatusUpdater implements DescriptorListener, }
private void processBridgeNetworkStatus(BridgeNetworkStatus status) { - SortedSet<String> fingerprints = new TreeSet<String>(); + SortedSet<String> fingerprints = new TreeSet<>(); for (NetworkStatusEntry entry : status.getStatusEntries().values()) { fingerprints.add(entry.getFingerprint()); @@ -145,15 +142,13 @@ public class UptimeStatusUpdater implements DescriptorListener, this.updateStatus(true, null, this.newRelayStatuses); for (Map.Entry<String, SortedSet<Long>> e : this.newRunningBridges.entrySet()) { - SortedMap<Long, Flags> dateHourMillisNoFlags = - new TreeMap<Long, Flags>(); + SortedMap<Long, Flags> dateHourMillisNoFlags = new TreeMap<>(); for (long dateHourMillis : e.getValue()) { dateHourMillisNoFlags.put(dateHourMillis, null); } this.updateStatus(false, e.getKey(), dateHourMillisNoFlags); } - SortedMap<Long, Flags> dateHourMillisNoFlags = - new TreeMap<Long, Flags>(); + SortedMap<Long, Flags> dateHourMillisNoFlags = new TreeMap<>(); for (long dateHourMillis : this.newBridgeStatuses) { dateHourMillisNoFlags.put(dateHourMillis, null); } diff --git a/src/main/java/org/torproject/onionoo/updater/WeightsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/WeightsStatusUpdater.java index 7ce1863..9ae60a9 100644 --- a/src/main/java/org/torproject/onionoo/updater/WeightsStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/WeightsStatusUpdater.java @@ -97,7 +97,7 @@ public class WeightsStatusUpdater implements DescriptorListener, SortedMap<String, Integer> bandwidthWeights = consensus.getBandwidthWeights(); if (bandwidthWeights != null) { - SortedSet<String> missingWeightKeys = new TreeSet<String>( + SortedSet<String> missingWeightKeys = new TreeSet<>( Arrays.asList("Wgg,Wgd,Wmg,Wmm,Wme,Wmd,Wee,Wed".split(","))); missingWeightKeys.removeAll(bandwidthWeights.keySet()); if (missingWeightKeys.isEmpty()) { @@ -112,14 +112,10 @@ public class WeightsStatusUpdater implements DescriptorListener, containsBandwidthWeights = true; } } - SortedMap<String, Double> consensusWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> guardWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> middleWeights = - new TreeMap<String, Double>(); - SortedMap<String, Double> exitWeights = - new TreeMap<String, Double>(); + SortedMap<String, Double> consensusWeights = new TreeMap<>(); + SortedMap<String, Double> guardWeights = new TreeMap<>(); + SortedMap<String, Double> middleWeights = new TreeMap<>(); + SortedMap<String, Double> exitWeights = new TreeMap<>(); double totalConsensusWeight = 0.0; double totalGuardWeight = 0.0; double totalMiddleWeight = 0.0; @@ -167,8 +163,7 @@ public class WeightsStatusUpdater implements DescriptorListener, } } } - SortedMap<String, double[]> pathSelectionProbabilities = - new TreeMap<String, double[]>(); + SortedMap<String, double[]> pathSelectionProbabilities = new TreeMap<>(); for (String fingerprint : consensusWeights.keySet()) { double[] probabilities = new double[] { -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 }; diff --git a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java index 84e42ce..a809aba 100644 --- a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java @@ -95,13 +95,12 @@ public class BandwidthDocumentWriter implements DocumentWriter {
private Map<String, GraphHistory> compileGraphType( SortedMap<Long, long[]> history) { - Map<String, GraphHistory> graphs = - new LinkedHashMap<String, GraphHistory>(); + Map<String, GraphHistory> graphs = new LinkedHashMap<>(); for (int i = 0; i < this.graphIntervals.length; i++) { String graphName = this.graphNames[i]; long graphInterval = this.graphIntervals[i]; long dataPointInterval = this.dataPointIntervals[i]; - List<Long> dataPoints = new ArrayList<Long>(); + List<Long> dataPoints = new ArrayList<>(); long intervalStartMillis = ((this.now - graphInterval) / dataPointInterval) * dataPointInterval; long totalMillis = 0L; @@ -180,7 +179,7 @@ public class BandwidthDocumentWriter implements DocumentWriter { graphHistory.setCount(count); int previousNonNullIndex = -2; boolean foundTwoAdjacentDataPoints = false; - List<Integer> values = new ArrayList<Integer>(); + List<Integer> values = new ArrayList<>(); for (int j = firstNonNullIndex; j <= lastNonNullIndex; j++) { long dataPoint = dataPoints.get(j); if (dataPoint >= 0L) { diff --git a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java index 868d5c1..fb262e9 100644 --- a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java @@ -112,8 +112,7 @@ public class ClientsDocumentWriter implements DocumentWriter { SortedSet<ClientsHistory> history) { ClientsDocument clientsDocument = new ClientsDocument(); clientsDocument.setFingerprint(hashedFingerprint); - Map<String, ClientsGraphHistory> averageClients = - new LinkedHashMap<String, ClientsGraphHistory>(); + Map<String, ClientsGraphHistory> averageClients = new LinkedHashMap<>(); for (int graphIntervalIndex = 0; graphIntervalIndex < this.graphIntervals.length; graphIntervalIndex++) { String graphName = this.graphNames[graphIntervalIndex]; @@ -132,18 +131,15 @@ public class ClientsDocumentWriter implements DocumentWriter { long graphInterval = this.graphIntervals[graphIntervalIndex]; long dataPointInterval = this.dataPointIntervals[graphIntervalIndex]; - List<Double> dataPoints = new ArrayList<Double>(); + List<Double> dataPoints = new ArrayList<>(); long intervalStartMillis = ((this.now - graphInterval) / dataPointInterval) * dataPointInterval; long millis = 0L; double responses = 0.0; double totalResponses = 0.0; - SortedMap<String, Double> totalResponsesByCountry = - new TreeMap<String, Double>(); - SortedMap<String, Double> totalResponsesByTransport = - new TreeMap<String, Double>(); - SortedMap<String, Double> totalResponsesByVersion = - new TreeMap<String, Double>(); + SortedMap<String, Double> totalResponsesByCountry = new TreeMap<>(); + SortedMap<String, Double> totalResponsesByTransport = new TreeMap<>(); + SortedMap<String, Double> totalResponsesByVersion = new TreeMap<>(); for (ClientsHistory hist : history) { if (hist.getEndMillis() < intervalStartMillis) { continue; @@ -231,7 +227,7 @@ public class ClientsDocumentWriter implements DocumentWriter { graphHistory.setCount(count); int previousNonNullIndex = -2; boolean foundTwoAdjacentDataPoints = false; - List<Integer> values = new ArrayList<Integer>(); + List<Integer> values = new ArrayList<>(); for (int dataPointIndex = firstNonNullIndex; dataPointIndex <= lastNonNullIndex; dataPointIndex++) { double dataPoint = dataPoints.get(dataPointIndex); @@ -246,7 +242,7 @@ public class ClientsDocumentWriter implements DocumentWriter { } graphHistory.setValues(values); if (!totalResponsesByCountry.isEmpty()) { - SortedMap<String, Float> countries = new TreeMap<String, Float>(); + SortedMap<String, Float> countries = new TreeMap<>(); for (Map.Entry<String, Double> e : totalResponsesByCountry.entrySet()) { if (e.getValue() > totalResponses / 100.0) { @@ -257,7 +253,7 @@ public class ClientsDocumentWriter implements DocumentWriter { graphHistory.setCountries(countries); } if (!totalResponsesByTransport.isEmpty()) { - SortedMap<String, Float> transports = new TreeMap<String, Float>(); + SortedMap<String, Float> transports = new TreeMap<>(); for (Map.Entry<String, Double> e : totalResponsesByTransport.entrySet()) { if (e.getValue() > totalResponses / 100.0) { @@ -268,7 +264,7 @@ public class ClientsDocumentWriter implements DocumentWriter { graphHistory.setTransports(transports); } if (!totalResponsesByVersion.isEmpty()) { - SortedMap<String, Float> versions = new TreeMap<String, Float>(); + SortedMap<String, Float> versions = new TreeMap<>(); for (Map.Entry<String, Double> e : totalResponsesByVersion.entrySet()) { if (e.getValue() > totalResponses / 100.0) { diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java index 5e3e175..e3f638d 100644 --- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java @@ -56,7 +56,7 @@ public class DetailsDocumentWriter implements DocumentWriter { DetailsDocument detailsDocument = new DetailsDocument(); detailsDocument.setNickname(detailsStatus.getNickname()); detailsDocument.setFingerprint(fingerprint); - List<String> orAddresses = new ArrayList<String>(); + List<String> orAddresses = new ArrayList<>(); orAddresses.add(detailsStatus.getAddress() + ":" + detailsStatus.getOrPort()); for (String orAddress : detailsStatus.getOrAddressesAndPorts()) { @@ -80,8 +80,7 @@ public class DetailsDocumentWriter implements DocumentWriter { String portList = detailsStatus.getPortList(); if (defaultPolicy != null && (defaultPolicy.equals("accept") || defaultPolicy.equals("reject")) && portList != null) { - Map<String, List<String>> exitPolicySummary = - new HashMap<String, List<String>>(); + Map<String, List<String>> exitPolicySummary = new HashMap<>(); List<String> portsOrPortRanges = Arrays.asList(portList.split(",")); exitPolicySummary.put(defaultPolicy, portsOrPortRanges); detailsDocument.setExitPolicySummary(exitPolicySummary); @@ -118,7 +117,7 @@ public class DetailsDocumentWriter implements DocumentWriter { detailsDocument.setPlatform(detailsStatus.getPlatform()); if (detailsStatus.getAllegedFamily() != null && !detailsStatus.getAllegedFamily().isEmpty()) { - SortedSet<String> allegedFamily = new TreeSet<String>(); + SortedSet<String> allegedFamily = new TreeSet<>(); for (String familyMember : detailsStatus.getAllegedFamily()) { if (familyMember.length() >= 40) { allegedFamily.add("$" + familyMember); @@ -130,7 +129,7 @@ public class DetailsDocumentWriter implements DocumentWriter { } if (detailsStatus.getEffectiveFamily() != null && !detailsStatus.getEffectiveFamily().isEmpty()) { - SortedSet<String> effectiveFamily = new TreeSet<String>(); + SortedSet<String> effectiveFamily = new TreeSet<>(); for (String familyMember : detailsStatus.getEffectiveFamily()) { effectiveFamily.add("$" + familyMember); } @@ -138,7 +137,7 @@ public class DetailsDocumentWriter implements DocumentWriter { } if (detailsStatus.getIndirectFamily() != null && !detailsStatus.getIndirectFamily().isEmpty()) { - SortedSet<String> indirectFamily = new TreeSet<String>(); + SortedSet<String> indirectFamily = new TreeSet<>(); for (String familyMember : detailsStatus.getIndirectFamily()) { indirectFamily.add("$" + familyMember); } @@ -149,10 +148,10 @@ public class DetailsDocumentWriter implements DocumentWriter { detailsDocument.setHibernating(detailsStatus.getHibernating()); if (detailsStatus.getExitAddresses() != null) { SortedSet<String> exitAddressesWithoutOrAddresses = - new TreeSet<String>(detailsStatus.getExitAddresses().keySet()); + new TreeSet<>(detailsStatus.getExitAddresses().keySet()); exitAddressesWithoutOrAddresses.removeAll( detailsStatus.getOrAddresses()); - detailsDocument.setExitAddresses(new ArrayList<String>( + detailsDocument.setExitAddresses(new ArrayList<>( exitAddressesWithoutOrAddresses)); } detailsDocument.setMeasured(detailsStatus.getMeasured()); @@ -165,7 +164,7 @@ public class DetailsDocumentWriter implements DocumentWriter { detailsDocument.setNickname(detailsStatus.getNickname()); detailsDocument.setHashedFingerprint(fingerprint); String address = detailsStatus.getAddress(); - List<String> orAddresses = new ArrayList<String>(); + List<String> orAddresses = new ArrayList<>(); orAddresses.add(address + ":" + detailsStatus.getOrPort()); SortedSet<String> orAddressesAndPorts = detailsStatus.getOrAddressesAndPorts(); diff --git a/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java index 24c7e0c..b2f678d 100644 --- a/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java @@ -65,7 +65,7 @@ public class SummaryDocumentWriter implements DocumentWriter { } continue; } - List<String> addresses = new ArrayList<String>(); + List<String> addresses = new ArrayList<>(); addresses.add(nodeStatus.getAddress()); for (String orAddress : nodeStatus.getOrAddresses()) { if (!addresses.contains(orAddress)) { diff --git a/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java index 42f5661..0154604 100644 --- a/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java @@ -107,8 +107,7 @@ public class UptimeDocumentWriter implements DocumentWriter { SortedSet<UptimeHistory> knownStatuses) { UptimeDocument uptimeDocument = new UptimeDocument(); uptimeDocument.setFingerprint(fingerprint); - Map<String, GraphHistory> uptime = - new LinkedHashMap<String, GraphHistory>(); + Map<String, GraphHistory> uptime = new LinkedHashMap<>(); for (int graphIntervalIndex = 0; graphIntervalIndex < this.graphIntervals.length; graphIntervalIndex++) { String graphName = this.graphNames[graphIntervalIndex]; @@ -119,17 +118,15 @@ public class UptimeDocumentWriter implements DocumentWriter { } } uptimeDocument.setUptime(uptime); - SortedMap<String, Map<String, GraphHistory>> flags = - new TreeMap<String, Map<String, GraphHistory>>(); - SortedSet<String> allFlags = new TreeSet<String>(); + SortedMap<String, Map<String, GraphHistory>> flags = new TreeMap<>(); + SortedSet<String> allFlags = new TreeSet<>(); for (UptimeHistory hist : history) { if (hist.getFlags() != null) { allFlags.addAll(hist.getFlags()); } } for (String flag : allFlags) { - Map<String, GraphHistory> graphsForFlags = - new LinkedHashMap<String, GraphHistory>(); + Map<String, GraphHistory> graphsForFlags = new LinkedHashMap<>(); for (int graphIntervalIndex = 0; graphIntervalIndex < this.graphIntervals.length; graphIntervalIndex++) { String graphName = this.graphNames[graphIntervalIndex]; @@ -157,7 +154,7 @@ public class UptimeDocumentWriter implements DocumentWriter { this.dataPointIntervals[graphIntervalIndex]; int dataPointIntervalHours = (int) (dataPointInterval / DateTimeHelper.ONE_HOUR); - List<Integer> uptimeDataPoints = new ArrayList<Integer>(); + List<Integer> uptimeDataPoints = new ArrayList<>(); long intervalStartMillis = ((this.now - graphInterval) / dataPointInterval) * dataPointInterval; int uptimeHours = 0; @@ -200,7 +197,7 @@ public class UptimeDocumentWriter implements DocumentWriter { / DateTimeHelper.ONE_HOUR); } uptimeDataPoints.add(uptimeHours); - List<Integer> statusDataPoints = new ArrayList<Integer>(); + List<Integer> statusDataPoints = new ArrayList<>(); intervalStartMillis = ((this.now - graphInterval) / dataPointInterval) * dataPointInterval; int statusHours = -1; @@ -246,7 +243,7 @@ public class UptimeDocumentWriter implements DocumentWriter { statusDataPoints.add(statusHours * 5 > dataPointIntervalHours ? statusHours : -1); } - List<Double> dataPoints = new ArrayList<Double>(); + List<Double> dataPoints = new ArrayList<>(); for (int dataPointIndex = 0; dataPointIndex < statusDataPoints.size(); dataPointIndex++) { if (dataPointIndex >= uptimeDataPoints.size()) { @@ -297,7 +294,7 @@ public class UptimeDocumentWriter implements DocumentWriter { graphHistory.setCount(count); int previousNonNullIndex = -2; boolean foundTwoAdjacentDataPoints = false; - List<Integer> values = new ArrayList<Integer>(); + List<Integer> values = new ArrayList<>(); for (int dataPointIndex = firstNonNullIndex; dataPointIndex <= lastNonNullIndex; dataPointIndex++) { double dataPoint = dataPoints.get(dataPointIndex); diff --git a/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java index 35ef3ae..5b45b78 100644 --- a/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java +++ b/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java @@ -98,8 +98,7 @@ public class WeightsDocumentWriter implements DocumentWriter {
private Map<String, GraphHistory> compileGraphType( SortedMap<long[], double[]> history, int graphTypeIndex) { - Map<String, GraphHistory> graphs = - new LinkedHashMap<String, GraphHistory>(); + Map<String, GraphHistory> graphs = new LinkedHashMap<>(); for (int graphIntervalIndex = 0; graphIntervalIndex < this.graphIntervals.length; graphIntervalIndex++) { String graphName = this.graphNames[graphIntervalIndex]; @@ -117,7 +116,7 @@ public class WeightsDocumentWriter implements DocumentWriter { long graphInterval = this.graphIntervals[graphIntervalIndex]; long dataPointInterval = this.dataPointIntervals[graphIntervalIndex]; - List<Double> dataPoints = new ArrayList<Double>(); + List<Double> dataPoints = new ArrayList<>(); long intervalStartMillis = ((this.now - graphInterval) / dataPointInterval) * dataPointInterval; long totalMillis = 0L; @@ -188,7 +187,7 @@ public class WeightsDocumentWriter implements DocumentWriter { graphHistory.setCount(count); int previousNonNullIndex = -2; boolean foundTwoAdjacentDataPoints = false; - List<Integer> values = new ArrayList<Integer>(); + List<Integer> values = new ArrayList<>(); for (int dataPointIndex = firstNonNullIndex; dataPointIndex <= lastNonNullIndex; dataPointIndex++) { double dataPoint = dataPoints.get(dataPointIndex); diff --git a/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java b/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java index e327b64..6fcd05b 100644 --- a/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java +++ b/src/test/java/org/torproject/onionoo/docs/BandwidthStatusTest.java @@ -69,8 +69,7 @@ public class BandwidthStatusTest { return this.intervalLength; }
- private SortedMap<Long, Long> bandwidthValues = - new TreeMap<>(); + private SortedMap<Long, Long> bandwidthValues = new TreeMap<>();
public SortedMap<Long, Long> getBandwidthValues() { return this.bandwidthValues; diff --git a/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java b/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java index 3c80cfa..4904044 100644 --- a/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java +++ b/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java @@ -20,8 +20,7 @@ public class DummyDocumentStore extends DocumentStore { private <T extends Document> SortedMap<String, Document> getStoredDocumentsByClass(Class<T> documentType) { if (!this.storedDocuments.containsKey(documentType)) { - this.storedDocuments.put(documentType, - new TreeMap<String, Document>()); + this.storedDocuments.put(documentType, new TreeMap<String, Document>()); } return this.storedDocuments.get(documentType); } @@ -63,7 +62,7 @@ public class DummyDocumentStore extends DocumentStore { public <T extends Document> SortedSet<String> list( Class<T> documentType) { this.performedListOperations++; - SortedSet<String> fingerprints = new TreeSet<String>( + SortedSet<String> fingerprints = new TreeSet<>( this.getStoredDocumentsByClass(documentType).keySet()); fingerprints.remove(FINGERPRINT_NULL); return fingerprints; diff --git a/src/test/java/org/torproject/onionoo/docs/NodeStatusTest.java b/src/test/java/org/torproject/onionoo/docs/NodeStatusTest.java index 2e7c3a3..284edd9 100644 --- a/src/test/java/org/torproject/onionoo/docs/NodeStatusTest.java +++ b/src/test/java/org/torproject/onionoo/docs/NodeStatusTest.java @@ -26,11 +26,11 @@ public class NodeStatusTest { private void assertFamiliesCanBeDeSerialized( String[] declaredFamilyArray, String[] effectiveFamilyArray, String[] extendedFamilyArray) { - SortedSet<String> declaredFamily = new TreeSet<String>( + SortedSet<String> declaredFamily = new TreeSet<>( Arrays.asList(declaredFamilyArray)); - SortedSet<String> effectiveFamily = new TreeSet<String>( + SortedSet<String> effectiveFamily = new TreeSet<>( Arrays.asList(effectiveFamilyArray)); - SortedSet<String> extendedFamily = new TreeSet<String>( + SortedSet<String> extendedFamily = new TreeSet<>( Arrays.asList(extendedFamilyArray)); NodeStatus nodeStatus = NodeStatus.fromString(GABELMOO_NODE_STATUS); nodeStatus.setDeclaredFamily(declaredFamily); diff --git a/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java b/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java index 359fa03..413ca83 100644 --- a/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java +++ b/src/test/java/org/torproject/onionoo/docs/SummaryDocumentTest.java @@ -18,14 +18,14 @@ public class SummaryDocumentTest { "000C5F55BD4814B917CC474BD537F1A3B33CCE2A", Arrays.asList( new String[] { "62.216.201.221", "62.216.201.222", "62.216.201.223" }), DateTimeHelper.parse("2013-04-19 05:00:00"), - false, new TreeSet<String>(Arrays.asList(new String[] { "Running", + false, new TreeSet<>(Arrays.asList(new String[] { "Running", "Valid" })), 20L, "de", DateTimeHelper.parse("2013-04-18 05:00:00"), "AS8767", "torkaz <klaus dot zufall at gmx dot de> " - + "fb-token:np5_g_83jmf=", new TreeSet<String>(Arrays.asList( + + "fb-token:np5_g_83jmf=", new TreeSet<>(Arrays.asList( new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC", "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B" })), - new TreeSet<String>(Arrays.asList( + new TreeSet<>(Arrays.asList( new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC" }))); }
diff --git a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java index b5fa157..0d95925 100644 --- a/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java +++ b/src/test/java/org/torproject/onionoo/docs/UptimeStatusTest.java @@ -208,7 +208,7 @@ public class UptimeStatusTest { }
private static final SortedSet<String> RUNNING_FLAG = - new TreeSet<String>(Arrays.asList(new String[] { "Running" })); + new TreeSet<>(Arrays.asList(new String[] { "Running" }));
@Test() public void testAddFlagsToNoFlagsEnd() { diff --git a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java index 9d47bd2..f17e228 100644 --- a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java +++ b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java @@ -136,29 +136,28 @@ public class ResourceServletTest { "000C5F55BD4814B917CC474BD537F1A3B33CCE2A", Arrays.asList( new String[] { "62.216.201.221", "62.216.201.222", "62.216.201.223" }), DateTimeHelper.parse("2013-04-19 05:00:00"), - false, new TreeSet<String>(Arrays.asList(new String[] { "Running", + false, new TreeSet<>(Arrays.asList(new String[] { "Running", "Valid" })), 20L, "de", DateTimeHelper.parse("2013-04-18 05:00:00"), "AS8767", "torkaz <klaus dot zufall at gmx dot de> " - + "fb-token:np5_g_83jmf=", new TreeSet<String>(Arrays.asList( + + "fb-token:np5_g_83jmf=", new TreeSet<>(Arrays.asList( new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC", "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B" })), - new TreeSet<String>(Arrays.asList( + new TreeSet<>(Arrays.asList( new String[] { "001C13B3A55A71B977CA65EC85539D79C653A3FC" }))); org.torproject.onionoo.docs.SummaryDocument relayFerrari458 = new org.torproject.onionoo.docs.SummaryDocument(true, "Ferrari458", "001C13B3A55A71B977CA65EC85539D79C653A3FC", Arrays.asList( new String[] { "68.38.171.200", "[2001:4f8:3:2e::51]" }), DateTimeHelper.parse("2013-04-24 12:00:00"), true, - new TreeSet<String>(Arrays.asList(new String[] { "Fast", "Named", + new TreeSet<>(Arrays.asList(new String[] { "Fast", "Named", "Running", "V2Dir", "Valid" })), 1140L, "us", - DateTimeHelper.parse("2013-02-12 16:00:00"), "AS7922", null, + DateTimeHelper.parse("2013-04-16 18:00:00"), "AS7922", null, new TreeSet<String>(Arrays.asList(new String[] { "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), - new TreeSet<String>(Arrays.asList(new String[] { + new TreeSet<>(Arrays.asList(new String[] { "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" }))); - this.relays = - new TreeMap<String, org.torproject.onionoo.docs.SummaryDocument>(); + this.relays = new TreeMap<>(); this.relays.put("000C5F55BD4814B917CC474BD537F1A3B33CCE2A", relayTorkaZ); this.relays.put("001C13B3A55A71B977CA65EC85539D79C653A3FC", @@ -168,7 +167,7 @@ public class ResourceServletTest { "0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B", Arrays.asList( new String[] { "89.69.68.246" }), DateTimeHelper.parse("2013-04-22 20:00:00"), false, - new TreeSet<String>(Arrays.asList(new String[] { "Fast", + new TreeSet<>(Arrays.asList(new String[] { "Fast", "Running", "Unnamed", "V2Dir", "Valid" })), 63L, "a1", DateTimeHelper.parse("2013-04-16 18:00:00"), "AS6830", "1024D/51E2A1C7 steven j. murdoch " @@ -176,14 +175,13 @@ public class ResourceServletTest { new TreeSet<String>(), new TreeSet<String>()); this.relays.put("0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B", relayTimMayTribute); - this.bridges = - new TreeMap<String, org.torproject.onionoo.docs.SummaryDocument>(); + this.bridges = new TreeMap<>(); org.torproject.onionoo.docs.SummaryDocument bridgeec2bridgercc7f31fe = new org.torproject.onionoo.docs.SummaryDocument(false, "ec2bridgercc7f31fe", "0000831B236DFF73D409AD17B40E2A728A53994F", Arrays.asList(new String[] { "10.199.7.176" }), DateTimeHelper.parse("2013-04-21 18:07:03"), false, - new TreeSet<String>(Arrays.asList(new String[] { "Valid" })), -1L, + new TreeSet<>(Arrays.asList(new String[] { "Valid" })), -1L, null, DateTimeHelper.parse("2013-04-20 15:37:04"), null, null, null, null); this.bridges.put("0000831B236DFF73D409AD17B40E2A728A53994F", @@ -193,7 +191,7 @@ public class ResourceServletTest { "0002D9BDBBC230BD9C78FF502A16E0033EF87E0C", Arrays.asList( new String[] { "10.0.52.84" }), DateTimeHelper.parse("2013-04-20 17:37:04"), false, - new TreeSet<String>(Arrays.asList(new String[] { "Valid" })), -1L, + new TreeSet<>(Arrays.asList(new String[] { "Valid" })), -1L, null, DateTimeHelper.parse("2013-04-14 07:07:05"), null, null, null, null); this.bridges.put("0002D9BDBBC230BD9C78FF502A16E0033EF87E0C", @@ -203,7 +201,7 @@ public class ResourceServletTest { "1FEDE50ED8DBA1DD9F9165F78C8131E4A44AB756", Arrays.asList( new String[] { "10.63.169.98" }), DateTimeHelper.parse("2013-04-24 01:07:04"), true, - new TreeSet<String>(Arrays.asList(new String[] { "Running", + new TreeSet<>(Arrays.asList(new String[] { "Running", "Valid" })), -1L, null, DateTimeHelper.parse("2013-01-16 21:07:04"), null, null, null, null); diff --git a/src/test/java/org/torproject/onionoo/updater/DummyConsensus.java b/src/test/java/org/torproject/onionoo/updater/DummyConsensus.java index 54d0161..9745aa4 100644 --- a/src/test/java/org/torproject/onionoo/updater/DummyConsensus.java +++ b/src/test/java/org/torproject/onionoo/updater/DummyConsensus.java @@ -74,7 +74,7 @@ public class DummyConsensus implements RelayNetworkStatusConsensus { return null; }
- private SortedSet<String> knownFlags = new TreeSet<String>(); + private SortedSet<String> knownFlags = new TreeSet<>();
public void addKnownFlag(String flag) { this.knownFlags.add(flag); diff --git a/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java b/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java index 990b011..2312ef9 100644 --- a/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java +++ b/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java @@ -13,8 +13,7 @@ import java.util.Set;
public class DummyDescriptorSource extends DescriptorSource {
- private Map<DescriptorType, Set<Descriptor>> descriptors = - new HashMap<DescriptorType, Set<Descriptor>>(); + private Map<DescriptorType, Set<Descriptor>> descriptors = new HashMap<>();
/** Fills the given collection with descriptors of the requested type. */ public void provideDescriptors(DescriptorType descriptorType, @@ -53,7 +52,7 @@ public class DummyDescriptorSource extends DescriptorSource {
@Override public void readDescriptors() { - Set<DescriptorType> descriptorTypes = new HashSet<DescriptorType>(); + Set<DescriptorType> descriptorTypes = new HashSet<>(); descriptorTypes.addAll(this.descriptorListeners.keySet()); for (DescriptorType descriptorType : descriptorTypes) { boolean relay; diff --git a/src/test/java/org/torproject/onionoo/updater/DummyStatusEntry.java b/src/test/java/org/torproject/onionoo/updater/DummyStatusEntry.java index da583b8..9da51fc 100644 --- a/src/test/java/org/torproject/onionoo/updater/DummyStatusEntry.java +++ b/src/test/java/org/torproject/onionoo/updater/DummyStatusEntry.java @@ -59,7 +59,7 @@ public class DummyStatusEntry implements NetworkStatusEntry { return null; }
- private SortedSet<String> flags = new TreeSet<String>(); + private SortedSet<String> flags = new TreeSet<>();
public void addFlag(String flag) { this.flags.add(flag); diff --git a/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java b/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java index bcd8571..6ffeaf6 100644 --- a/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java +++ b/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java @@ -32,12 +32,12 @@ public class LookupServiceTest {
private LookupService lookupService;
- private SortedSet<String> addressStrings = new TreeSet<String>(); + private SortedSet<String> addressStrings = new TreeSet<>();
private SortedMap<String, LookupResult> lookupResults;
private void populateLines() { - this.geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + this.geoLite2CityBlocksIPv4Lines = new ArrayList<>(); this.geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -48,7 +48,7 @@ public class LookupServiceTest { + "0,94035,37.3860,-122.0838"); this.geoLite2CityBlocksIPv4Lines.add("8.8.9.0/24,6252001,6252001,,0," + "0,,38.0000,-97.0000"); - this.geoLite2CityLocationsEnLines = new ArrayList<String>(); + this.geoLite2CityLocationsEnLines = new ArrayList<>(); this.geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -59,7 +59,7 @@ public class LookupServiceTest { this.geoLite2CityLocationsEnLines.add("5375480,en,NA," + ""North America",US,"United States",CA,California,,," + ""Mountain View",807,America/Los_Angeles"); - this.geoipAsNum2Lines = new ArrayList<String>(); + this.geoipAsNum2Lines = new ArrayList<>(); this.geoipAsNum2Lines.add("134743296,134744063,"AS3356 Level 3 " + "Communications""); this.geoipAsNum2Lines.add("134744064,134744319,"AS15169 Google " @@ -252,7 +252,7 @@ public class LookupServiceTest {
@Test() public void testLookupNoCorrespondingLocation() { - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -267,7 +267,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksStartNotANumber() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -281,7 +281,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksLocationX() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -294,7 +294,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksLocationEmpty() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -307,7 +307,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksTooFewFields() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -320,7 +320,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksExtraneousField() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -334,7 +334,7 @@ public class LookupServiceTest {
@Test() public void testLookupBlocksThreeExtraneousFields() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -348,7 +348,7 @@ public class LookupServiceTest {
@Test() public void testLookupLocationLocIdNotANumber() { - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -363,7 +363,7 @@ public class LookupServiceTest {
@Test() public void testLookupLocationTooFewFields() { - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -378,7 +378,7 @@ public class LookupServiceTest {
@Test() public void testLookupGeoipAsNum2EndBeforeStart() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("134743296,134744063,"AS3356 Level 3 " + "Communications""); geoipAsNum2Lines.add("134744319,134744064,"AS15169 Google Inc.""); @@ -391,7 +391,7 @@ public class LookupServiceTest {
@Test() public void testLookupGeoipAsNum2StartNotANumber() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("one,134744319,"AS15169 Google Inc.""); this.assertLookupResult(null, null, geoipAsNum2Lines, "8.8.8.8", null, null, null, null, null, null, null, null); @@ -399,7 +399,7 @@ public class LookupServiceTest {
@Test() public void testLookupGeoipAsNum2StartTooLarge() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("1" + String.valueOf(Long.MAX_VALUE) + ",134744319,"AS15169 Google Inc.""); this.assertLookupResult(null, null, geoipAsNum2Lines, "8.8.8.8", null, @@ -408,7 +408,7 @@ public class LookupServiceTest {
@Test() public void testLookupGeoipAsNum2TooFewFields() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("134744064,134744319"); this.assertLookupResult(null, null, geoipAsNum2Lines, "8.8.8.8", null, null, null, null, null, null, null, null); @@ -416,7 +416,7 @@ public class LookupServiceTest {
@Test() public void testLookupGeoipAsNum2NoAsName() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("134743296,134744063,AS3356"); geoipAsNum2Lines.add("134744064,134744319,AS15169"); geoipAsNum2Lines.add("134744320,134750463,AS3356"); @@ -428,7 +428,7 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationTurkey() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," @@ -441,7 +441,7 @@ public class LookupServiceTest { + "40.0781,29.5133"); geoLite2CityBlocksIPv4Lines.add("81.215.1.0/24,749748,298795,,0,0,," + "40.6000,33.6153"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -476,14 +476,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationLatvia() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("78.28.192.0/24,456202,458258,,0,0,," + "56.5000,27.3167"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -499,14 +499,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationAzerbaijan() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("94.20.148.0/24,585170,587116,,0,0,," + "41.1919,47.1706"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -523,14 +523,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationVietnam() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("115.78.92.0/23,1587976,1562822,,0,0," + ",10.2333,106.3833"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -547,14 +547,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationJapan() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("113.154.131.0/24,1848333,1861060,,0," + "0,1012236,35.8000,139.1833"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -571,14 +571,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationDenmark() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("2.110.246.0/24,2625001,2623032,,0,0," + "5970,54.8880,10.4112"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -596,14 +596,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationGermany() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("37.209.30.128/25,2947444,2921044,,0," + "0,,48.6833,9.0167"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -621,14 +621,14 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationPoland() { - List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<String>(); + List<String> geoLite2CityBlocksIPv4Lines = new ArrayList<>(); geoLite2CityBlocksIPv4Lines.add("network,geoname_id," + "registered_country_geoname_id,represented_country_geoname_id," + "is_anonymous_proxy,is_satellite_provider,postal_code,latitude," + "longitude"); geoLite2CityBlocksIPv4Lines.add("5.185.94.0/24,3099434,798544,,0,0,," + "54.3608,18.6583"); - List<String> geoLite2CityLocationsEnLines = new ArrayList<String>(); + List<String> geoLite2CityLocationsEnLines = new ArrayList<>(); geoLite2CityLocationsEnLines.add("geoname_id,locale_code," + "continent_code,continent_name,country_iso_code,country_name," + "subdivision_1_iso_code,subdivision_1_name," @@ -645,7 +645,7 @@ public class LookupServiceTest { @Test() @SuppressWarnings("AvoidEscapedUnicodeCharacters") public void testLookupLocationAsNameNonAscii() { - List<String> geoipAsNum2Lines = new ArrayList<String>(); + List<String> geoipAsNum2Lines = new ArrayList<>(); geoipAsNum2Lines.add("3207917568,3207919615,"AS52693 Conectel " + "Telecomunica\u00E7\u00F5es e Inform\u00E1tica Ltda ME""); geoipAsNum2Lines.add("3211196416,3211198463,"AS262934 "