commit 38bd70aecb7b6c0a1440a31ec0a5585b2a2c8ef4 Author: Karsten Loesing karsten.loesing@gmx.net Date: Mon Aug 20 15:05:33 2018 +0200
Use diamond operator. --- .../org/torproject/onionoo/docs/DetailsDocument.java | 2 +- .../org/torproject/onionoo/docs/DetailsStatus.java | 2 +- .../java/org/torproject/onionoo/docs/NodeStatus.java | 2 +- .../org/torproject/onionoo/server/NodeIndexer.java | 20 ++++++++++---------- .../onionoo/updater/ClientsStatusUpdater.java | 2 +- .../torproject/onionoo/updater/DescriptorSource.java | 2 +- .../onionoo/updater/NodeDetailsStatusUpdater.java | 2 +- .../onionoo/updater/RdnsLookupRequest.java | 2 +- .../onionoo/updater/UptimeStatusUpdater.java | 4 ++-- .../torproject/onionoo/docs/DummyDocumentStore.java | 2 +- .../onionoo/server/ResourceServletTest.java | 10 +++++----- .../onionoo/updater/DummyDescriptorSource.java | 4 ++-- .../onionoo/updater/LookupServiceTest.java | 6 +++--- 13 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java index 5e53d4c..504f0b5 100644 --- a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java +++ b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java @@ -76,7 +76,7 @@ public class DetailsDocument extends Document { }
public List<String> getExitAddresses() { - return this.exitAddresses == null ? new ArrayList<String>() + return this.exitAddresses == null ? new ArrayList<>() : this.exitAddresses; }
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java index 7cd87ee..31762d3 100644 --- a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java @@ -248,7 +248,7 @@ public class DetailsStatus extends Document { }
public SortedSet<String> getOrAddressesAndPorts() { - return this.orAddressesAndPorts == null ? new TreeSet<String>() : + return this.orAddressesAndPorts == null ? new TreeSet<>() : this.orAddressesAndPorts; }
diff --git a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java index c0c6adf..bef403b 100644 --- a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java +++ b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java @@ -182,7 +182,7 @@ public class NodeStatus extends Document { }
public SortedSet<String> getOrAddressesAndPorts() { - return this.orAddressesAndPorts == null ? new TreeSet<String>() + return this.orAddressesAndPorts == null ? new TreeSet<>() : this.orAddressesAndPorts; }
diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java index 3812fea..350a3ef 100644 --- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java +++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java @@ -211,7 +211,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { } if (!newRelaysByCountryCode.containsKey(countryCode)) { newRelaysByCountryCode.put(countryCode, - new HashSet<String>()); + new HashSet<>()); } newRelaysByCountryCode.get(countryCode).add(fingerprint); newRelaysByCountryCode.get(countryCode).add(hashedFingerprint); @@ -226,7 +226,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { asNumber = "AS0"; } if (!newRelaysByAsNumber.containsKey(asNumber)) { - newRelaysByAsNumber.put(asNumber, new HashSet<String>()); + newRelaysByAsNumber.put(asNumber, new HashSet<>()); } newRelaysByAsNumber.get(asNumber).add(fingerprint); newRelaysByAsNumber.get(asNumber).add(hashedFingerprint); @@ -239,7 +239,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { for (String flag : entry.getRelayFlags()) { String flagLowerCase = flag.toLowerCase(); if (!newRelaysByFlag.containsKey(flagLowerCase)) { - newRelaysByFlag.put(flagLowerCase, new HashSet<String>()); + newRelaysByFlag.put(flagLowerCase, new HashSet<>()); } newRelaysByFlag.get(flagLowerCase).add(fingerprint); newRelaysByFlag.get(flagLowerCase).add(hashedFingerprint); @@ -260,7 +260,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { - entry.getFirstSeenMillis()) / ONE_DAY); if (!newRelaysByFirstSeenDays.containsKey(daysSinceFirstSeen)) { newRelaysByFirstSeenDays.put(daysSinceFirstSeen, - new HashSet<String>()); + new HashSet<>()); } newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add(fingerprint); newRelaysByFirstSeenDays.get(daysSinceFirstSeen).add( @@ -270,21 +270,21 @@ public class NodeIndexer implements ServletContextListener, Runnable { - entry.getLastSeenMillis()) / ONE_DAY); if (!newRelaysByLastSeenDays.containsKey(daysSinceLastSeen)) { newRelaysByLastSeenDays.put(daysSinceLastSeen, - new HashSet<String>()); + new HashSet<>()); } newRelaysByLastSeenDays.get(daysSinceLastSeen).add(fingerprint); newRelaysByLastSeenDays.get(daysSinceLastSeen).add( hashedFingerprint); String contact = entry.getContact(); if (!newRelaysByContact.containsKey(contact)) { - newRelaysByContact.put(contact, new HashSet<String>()); + newRelaysByContact.put(contact, new HashSet<>()); } newRelaysByContact.get(contact).add(fingerprint); newRelaysByContact.get(contact).add(hashedFingerprint); String version = entry.getVersion(); if (null != version) { if (!newRelaysByVersion.containsKey(version)) { - newRelaysByVersion.put(version, new HashSet<String>()); + newRelaysByVersion.put(version, new HashSet<>()); } newRelaysByVersion.get(version).add(fingerprint); newRelaysByVersion.get(version).add(hashedFingerprint); @@ -347,7 +347,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { for (String flag : entry.getRelayFlags()) { String flagLowerCase = flag.toLowerCase(); if (!newBridgesByFlag.containsKey(flagLowerCase)) { - newBridgesByFlag.put(flagLowerCase, new HashSet<String>()); + newBridgesByFlag.put(flagLowerCase, new HashSet<>()); } newBridgesByFlag.get(flagLowerCase).add(hashedFingerprint); newBridgesByFlag.get(flagLowerCase).add( @@ -358,7 +358,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { - entry.getFirstSeenMillis()) / ONE_DAY); if (!newBridgesByFirstSeenDays.containsKey(daysSinceFirstSeen)) { newBridgesByFirstSeenDays.put(daysSinceFirstSeen, - new HashSet<String>()); + new HashSet<>()); } newBridgesByFirstSeenDays.get(daysSinceFirstSeen).add( hashedFingerprint); @@ -369,7 +369,7 @@ public class NodeIndexer implements ServletContextListener, Runnable { - entry.getLastSeenMillis()) / ONE_DAY); if (!newBridgesByLastSeenDays.containsKey(daysSinceLastSeen)) { newBridgesByLastSeenDays.put(daysSinceLastSeen, - new HashSet<String>()); + new HashSet<>()); } newBridgesByLastSeenDays.get(daysSinceLastSeen).add( hashedFingerprint); diff --git a/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java index 0529dcf..8265f43 100644 --- a/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/ClientsStatusUpdater.java @@ -116,7 +116,7 @@ public class ClientsStatusUpdater implements DescriptorListener, responsesByTransport, responsesByVersion); if (!this.newResponses.containsKey(hashedFingerprint)) { this.newResponses.put(hashedFingerprint, - new TreeSet<ClientsHistory>()); + new TreeSet<>()); } this.newResponses.get(hashedFingerprint).add( newResponseHistory); diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java index 20e249d..64bb0e4 100644 --- a/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java +++ b/src/main/java/org/torproject/onionoo/updater/DescriptorSource.java @@ -83,7 +83,7 @@ public class DescriptorSource { DescriptorType descriptorType) { if (!this.descriptorListeners.containsKey(descriptorType)) { this.descriptorListeners.put(descriptorType, - new HashSet<DescriptorListener>()); + new HashSet<>()); } this.descriptorListeners.get(descriptorType).add(listener); } diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java index 507d633..82cea1b 100644 --- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java @@ -224,7 +224,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 exitAddress = exitAddressScanMillis.getKey(); if (!this.exitListEntries.get(fingerprint).containsKey( diff --git a/src/main/java/org/torproject/onionoo/updater/RdnsLookupRequest.java b/src/main/java/org/torproject/onionoo/updater/RdnsLookupRequest.java index 380b62c..9f3c6cf 100644 --- a/src/main/java/org/torproject/onionoo/updater/RdnsLookupRequest.java +++ b/src/main/java/org/torproject/onionoo/updater/RdnsLookupRequest.java @@ -91,7 +91,7 @@ class RdnsLookupRequest extends Thread { envProps.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); final DirContext dnsContext = new InitialDirContext(envProps); - Set<String> results = new TreeSet<String>(); + Set<String> results = new TreeSet<>(); Attributes dnsEntries = dnsContext.getAttributes(hostName, new String[] { type }); if (dnsEntries != null) { diff --git a/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java index 8405bf8..338bf58 100644 --- a/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java +++ b/src/main/java/org/torproject/onionoo/updater/UptimeStatusUpdater.java @@ -105,7 +105,7 @@ public class UptimeStatusUpdater implements DescriptorListener, String fingerprint = entry.getFingerprint(); if (!this.newRunningRelays.containsKey(fingerprint)) { this.newRunningRelays.put(fingerprint, - new TreeMap<Long, Flags>()); + new TreeMap<>()); } this.newRunningRelays.get(fingerprint).put(dateHourMillis, new Flags(entry.getFlags())); @@ -125,7 +125,7 @@ public class UptimeStatusUpdater implements DescriptorListener, / DateTimeHelper.ONE_HOUR) * DateTimeHelper.ONE_HOUR; for (String fingerprint : fingerprints) { if (!this.newRunningBridges.containsKey(fingerprint)) { - this.newRunningBridges.put(fingerprint, new TreeSet<Long>()); + this.newRunningBridges.put(fingerprint, new TreeSet<>()); } this.newRunningBridges.get(fingerprint).add(dateHourMillis); } diff --git a/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java b/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java index 8827725..3c79235 100644 --- a/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java +++ b/src/test/java/org/torproject/onionoo/docs/DummyDocumentStore.java @@ -20,7 +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<>()); } return this.storedDocuments.get(documentType); } diff --git a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java index 0be1635..063f550 100644 --- a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java +++ b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java @@ -56,7 +56,7 @@ public class ResourceServletTest { this.requestUri = requestUri; this.queryString = queryString; this.parameterMap = parameterMap == null - ? new HashMap<String, String[]>() : parameterMap; + ? new HashMap<>() : parameterMap; }
@Override @@ -162,8 +162,8 @@ public class ResourceServletTest { "Running", "V2Dir", "Valid" })), 1140L, "us", DateTimeHelper.parse("2013-04-16 18:00:00"), "AS7922", "comcast cable communications, llc", null, - new TreeSet<String>(Arrays.asList(new String[] { - "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), + new TreeSet<>(Arrays.asList(new String[]{ + "000C5F55BD4814B917CC474BD537F1A3B33CCE2A"})), new TreeSet<>(Arrays.asList(new String[] { "000C5F55BD4814B917CC474BD537F1A3B33CCE2A" })), null, null, new TreeSet<>(Arrays.asList( @@ -182,7 +182,7 @@ public class ResourceServletTest { "liberty global operations b.v.", "1024d/51e2a1c7 "steven j. murdoch" " + "tor+steven.murdoch@cl.cam.ac.uk fb-token:5sr_k_zs2wm=", - new TreeSet<String>(), new TreeSet<String>(), "0.2.3.24-rc-dev", + new TreeSet<>(), new TreeSet<>(), "0.2.3.24-rc-dev", "windows xp", null, null, false); this.relays.put("0025C136C1F3A9EEFE2AE3F918F03BFA21B5070B", relayTimMayTribute); @@ -337,7 +337,7 @@ public class ResourceServletTest { String[] parameterParts = parameter.split("="); if (!parameterLists.containsKey(parameterParts[0])) { parameterLists.put(parameterParts[0], - new ArrayList<String>()); + new ArrayList<>()); } parameterLists.get(parameterParts[0]).add(parameterParts[1]); } diff --git a/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java b/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java index c311b2b..c985090 100644 --- a/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java +++ b/src/test/java/org/torproject/onionoo/updater/DummyDescriptorSource.java @@ -32,7 +32,7 @@ public class DummyDescriptorSource extends DescriptorSource { private Set<Descriptor> getDescriptorsByType( DescriptorType descriptorType) { if (!this.descriptors.containsKey(descriptorType)) { - this.descriptors.put(descriptorType, new HashSet<Descriptor>()); + this.descriptors.put(descriptorType, new HashSet<>()); } return this.descriptors.get(descriptorType); } @@ -45,7 +45,7 @@ public class DummyDescriptorSource extends DescriptorSource { DescriptorType descriptorType) { if (!this.descriptorListeners.containsKey(descriptorType)) { this.descriptorListeners.put(descriptorType, - new HashSet<DescriptorListener>()); + new HashSet<>()); } this.descriptorListeners.get(descriptorType).add(listener); } diff --git a/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java b/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java index 6311316..743fe1d 100644 --- a/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java +++ b/src/test/java/org/torproject/onionoo/updater/LookupServiceTest.java @@ -234,19 +234,19 @@ public class LookupServiceTest {
@Test() public void testLookupNoBlocksLines() { - this.assertLookupResult(new ArrayList<String>(), null, null, + this.assertLookupResult(new ArrayList<>(), null, null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoLocationLines() { - this.assertLookupResult(null, new ArrayList<String>(), null, + this.assertLookupResult(null, new ArrayList<>(), null, "8.8.8.8", null, null, null, null, null, null, null, null); }
@Test() public void testLookupNoGeoipAsNum2Lines() { - this.assertLookupResult(null, null, new ArrayList<String>(), + this.assertLookupResult(null, null, new ArrayList<>(), "8.8.8.8", null, null, null, null, null, null, null, null); }
tor-commits@lists.torproject.org