mirror of
https://github.com/torproject/collector.git
synced 2024-11-23 09:29:46 +00:00
Use Java 5 and 7 idioms in more places.
This commit is contained in:
parent
dafd7ed246
commit
3ba8bdcc16
@ -307,8 +307,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
|
||||
/* Invalid IPv6 address. */
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
String part = parts[i];
|
||||
for (String part : parts) {
|
||||
if (part.contains(".")) {
|
||||
String[] ipParts = part.split("\\.");
|
||||
byte[] ipv4Bytes = new byte[4];
|
||||
|
@ -263,8 +263,8 @@ public class Configuration extends Observable implements Cloneable {
|
||||
try {
|
||||
checkClass(key, SourceType[].class);
|
||||
String[] interim = props.getProperty(key.name()).split(FIELDSEP);
|
||||
for (int i = 0; i < interim.length; i++) {
|
||||
SourceType st = SourceType.valueOf(interim[i].trim());
|
||||
for (String anInterim : interim) {
|
||||
SourceType st = SourceType.valueOf(anInterim.trim());
|
||||
if (null == res) {
|
||||
res = EnumSet.of(st);
|
||||
} else {
|
||||
|
@ -276,7 +276,7 @@ public class ArchiveReader {
|
||||
if (!this.microdescriptorValidAfterTimes.containsKey(
|
||||
microdescriptor)) {
|
||||
this.microdescriptorValidAfterTimes.put(microdescriptor,
|
||||
new HashSet<String>());
|
||||
new HashSet<>());
|
||||
}
|
||||
this.microdescriptorValidAfterTimes.get(microdescriptor).add(
|
||||
validAfterTime);
|
||||
|
@ -230,8 +230,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
continue;
|
||||
}
|
||||
if (!this.storedServerDescriptors.containsKey(published)) {
|
||||
this.storedServerDescriptors.put(published,
|
||||
new HashMap<String, String>());
|
||||
this.storedServerDescriptors.put(published, new HashMap<>());
|
||||
}
|
||||
String serverDescriptorDigest = parts[1];
|
||||
String extraInfoDescriptorDigest = parts[2].equals("NA") ? null
|
||||
@ -259,8 +258,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
continue;
|
||||
}
|
||||
if (!this.storedExtraInfoDescriptors.containsKey(published)) {
|
||||
this.storedExtraInfoDescriptors.put(published,
|
||||
new HashSet<String>());
|
||||
this.storedExtraInfoDescriptors.put(published, new HashSet<>());
|
||||
}
|
||||
String extraInfoDescriptorDigest = parts[1];
|
||||
this.storedExtraInfoDescriptors.get(published).add(
|
||||
@ -286,8 +284,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
continue;
|
||||
}
|
||||
if (!this.storedMicrodescriptors.containsKey(validAfter)) {
|
||||
this.storedMicrodescriptors.put(validAfter,
|
||||
new HashSet<String>());
|
||||
this.storedMicrodescriptors.put(validAfter, new HashSet<>());
|
||||
}
|
||||
String microdescriptorDigest = parts[1];
|
||||
this.storedMicrodescriptors.get(validAfter).add(
|
||||
@ -706,8 +703,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
if (!tarballFileExistedBefore
|
||||
&& this.now - validAfter < 3L * 60L * 60L * 1000L) {
|
||||
if (!this.storedVotes.containsKey(validAfter)) {
|
||||
this.storedVotes.put(validAfter,
|
||||
new TreeMap<String, SortedSet<String>>());
|
||||
this.storedVotes.put(validAfter, new TreeMap<>());
|
||||
}
|
||||
this.storedVotes.get(validAfter).put(fingerprint,
|
||||
serverDescriptorDigests);
|
||||
@ -750,8 +746,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
if (!tarballFileExistedBefore
|
||||
&& this.now - published < 48L * 60L * 60L * 1000L) {
|
||||
if (!this.storedServerDescriptors.containsKey(published)) {
|
||||
this.storedServerDescriptors.put(published,
|
||||
new HashMap<String, String>());
|
||||
this.storedServerDescriptors.put(published, new HashMap<>());
|
||||
}
|
||||
this.storedServerDescriptors.get(published).put(digest,
|
||||
extraInfoDigest);
|
||||
@ -779,8 +774,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
if (!tarballFileExistedBefore
|
||||
&& this.now - published < 48L * 60L * 60L * 1000L) {
|
||||
if (!this.storedExtraInfoDescriptors.containsKey(published)) {
|
||||
this.storedExtraInfoDescriptors.put(published,
|
||||
new HashSet<String>());
|
||||
this.storedExtraInfoDescriptors.put(published, new HashSet<>());
|
||||
}
|
||||
this.storedExtraInfoDescriptors.get(published).add(extraInfoDigest);
|
||||
}
|
||||
@ -815,8 +809,7 @@ public class ArchiveWriter extends CollecTorMain {
|
||||
if (!tarballFileExistedBefore
|
||||
&& this.now - validAfter < 40L * 24L * 60L * 60L * 1000L) {
|
||||
if (!this.storedMicrodescriptors.containsKey(validAfter)) {
|
||||
this.storedMicrodescriptors.put(validAfter,
|
||||
new HashSet<String>());
|
||||
this.storedMicrodescriptors.put(validAfter, new HashSet<>());
|
||||
}
|
||||
this.storedMicrodescriptors.get(validAfter).add(
|
||||
microdescriptorDigest);
|
||||
|
@ -28,7 +28,6 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
@ -170,10 +169,8 @@ public class ReferenceChecker {
|
||||
DescriptorReader descriptorReader =
|
||||
DescriptorSourceFactory.createDescriptorReader();
|
||||
descriptorReader.setHistoryFile(this.historyFile);
|
||||
Iterator<Descriptor> descriptors
|
||||
= descriptorReader.readDescriptors(this.descriptorsDir).iterator();
|
||||
while (descriptors.hasNext()) {
|
||||
Descriptor descriptor = descriptors.next();
|
||||
for (Descriptor descriptor
|
||||
: descriptorReader.readDescriptors(this.descriptorsDir)) {
|
||||
if (descriptor instanceof RelayNetworkStatusConsensus) {
|
||||
RelayNetworkStatusConsensus consensus =
|
||||
(RelayNetworkStatusConsensus) descriptor;
|
||||
|
@ -383,7 +383,7 @@ public class RelayDescriptorDownloader {
|
||||
if (!this.microdescriptorKeys.containsKey(
|
||||
microdescriptorDigest)) {
|
||||
this.microdescriptorKeys.put(
|
||||
microdescriptorDigest, new HashSet<String>());
|
||||
microdescriptorDigest, new HashSet<>());
|
||||
}
|
||||
this.microdescriptorKeys.get(microdescriptorDigest).add(
|
||||
microdescriptorKey);
|
||||
@ -552,7 +552,7 @@ public class RelayDescriptorDownloader {
|
||||
}
|
||||
} else {
|
||||
this.microdescriptorKeys.put(
|
||||
microdescriptorDigest, new HashSet<String>());
|
||||
microdescriptorDigest, new HashSet<>());
|
||||
}
|
||||
this.microdescriptorKeys.get(microdescriptorDigest).add(
|
||||
microdescriptorKey);
|
||||
|
@ -316,10 +316,7 @@ public class RelayDescriptorParser {
|
||||
* storeMicrodescriptor below. */
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Could not parse descriptor. "
|
||||
+ "Skipping.", e);
|
||||
} catch (ParseException e) {
|
||||
} catch (IOException | ParseException e) {
|
||||
logger.warn("Could not parse descriptor. "
|
||||
+ "Skipping.", e);
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ public class LogFileMap
|
||||
TreeMap<String, TreeMap<LocalDate, LogMetadata>> virtualHosts
|
||||
= this.get(metadata.virtualHost);
|
||||
if (null == virtualHosts) {
|
||||
virtualHosts = new TreeMap<String, TreeMap<LocalDate, LogMetadata>>();
|
||||
virtualHosts = new TreeMap<>();
|
||||
this.put(metadata.virtualHost, virtualHosts);
|
||||
}
|
||||
TreeMap<LocalDate, LogMetadata> physicalHosts
|
||||
= virtualHosts.get(metadata.physicalHost);
|
||||
if (null == physicalHosts) {
|
||||
physicalHosts = new TreeMap<LocalDate, LogMetadata>();
|
||||
physicalHosts = new TreeMap<>();
|
||||
virtualHosts.put(metadata.physicalHost, physicalHosts);
|
||||
}
|
||||
physicalHosts.put(metadata.date, metadata);
|
||||
|
Loading…
Reference in New Issue
Block a user