[metrics-lib/master] Use Java 7's diamond operator wherever possible.

commit ce18717907b502dfbc87f4b8567652ffe10fefe5 Author: Karsten Loesing <karsten.loesing@gmx.net> Date: Tue Dec 22 11:42:15 2015 +0100 Use Java 7's diamond operator wherever possible. In many cases, the compiler will now infer which parameter types a new object shall have, which allows us to make our code less verbose. Suggested by iwakeh, implements #17823. --- .../descriptor/impl/BandwidthHistoryImpl.java | 2 +- .../descriptor/impl/BlockingIteratorImpl.java | 2 +- .../impl/BridgeExtraInfoDescriptorImpl.java | 3 +- .../descriptor/impl/BridgeNetworkStatusImpl.java | 2 +- .../descriptor/impl/BridgePoolAssignmentImpl.java | 10 +++--- .../impl/BridgeServerDescriptorImpl.java | 3 +- .../descriptor/impl/DescriptorCollectorImpl.java | 13 ++++---- .../descriptor/impl/DescriptorDownloaderImpl.java | 6 ++-- .../descriptor/impl/DescriptorFileImpl.java | 2 +- .../torproject/descriptor/impl/DescriptorImpl.java | 13 ++++---- .../descriptor/impl/DescriptorReaderImpl.java | 21 ++++++------- .../descriptor/impl/DirSourceEntryImpl.java | 6 ++-- .../impl/DirectoryKeyCertificateImpl.java | 9 +++--- .../descriptor/impl/DirectorySignatureImpl.java | 2 +- .../descriptor/impl/DownloadCoordinatorImpl.java | 16 +++++----- .../descriptor/impl/ExitListEntryImpl.java | 2 +- .../torproject/descriptor/impl/ExitListImpl.java | 6 ++-- .../descriptor/impl/ExtraInfoDescriptorImpl.java | 32 ++++++++++---------- .../descriptor/impl/MicrodescriptorImpl.java | 13 ++++---- .../descriptor/impl/NetworkStatusEntryImpl.java | 20 ++++++------ .../descriptor/impl/NetworkStatusImpl.java | 21 ++++++------- .../torproject/descriptor/impl/ParseHelper.java | 13 ++++---- .../descriptor/impl/RelayDirectoryImpl.java | 31 +++++++++---------- .../impl/RelayExtraInfoDescriptorImpl.java | 3 +- .../impl/RelayNetworkStatusConsensusImpl.java | 18 +++++------ .../descriptor/impl/RelayNetworkStatusImpl.java | 13 ++++---- .../impl/RelayNetworkStatusVoteImpl.java | 15 +++++---- .../descriptor/impl/RelayServerDescriptorImpl.java | 3 +- .../descriptor/impl/ServerDescriptorImpl.java | 18 +++++------ .../descriptor/impl/TorperfResultImpl.java | 12 ++++---- .../descriptor/impl/BridgeNetworkStatusTest.java | 2 +- .../descriptor/impl/ConsensusBuilder.java | 6 ++-- .../impl/ExtraInfoDescriptorImplTest.java | 2 +- .../impl/RelayNetworkStatusConsensusImplTest.java | 10 +++--- .../impl/RelayNetworkStatusVoteImplTest.java | 6 ++-- .../descriptor/impl/ServerDescriptorImplTest.java | 6 ++-- 36 files changed, 170 insertions(+), 192 deletions(-) diff --git a/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java b/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java index 136a6d7..0023b88 100644 --- a/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java +++ b/src/org/torproject/descriptor/impl/BandwidthHistoryImpl.java @@ -82,7 +82,7 @@ public class BandwidthHistoryImpl implements BandwidthHistory { private long[] bandwidthValues; public SortedMap<Long, Long> getBandwidthValues() { - SortedMap<Long, Long> result = new TreeMap<Long, Long>(); + SortedMap<Long, Long> result = new TreeMap<>(); if (this.bandwidthValues != null) { long endMillis = this.historyEndMillis; for (int i = this.bandwidthValues.length - 1; i >= 0; i--) { diff --git a/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java b/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java index aee669f..b4ea525 100644 --- a/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java +++ b/src/org/torproject/descriptor/impl/BlockingIteratorImpl.java @@ -13,7 +13,7 @@ import java.util.Queue; public class BlockingIteratorImpl<T> implements Iterator<T> { /* Queue containing produced elemnts waiting for consumers. */ - private Queue<T> queue = new LinkedList<T>(); + private Queue<T> queue = new LinkedList<>(); /* Maximum number of elements in queue. */ private int maxQueueSize = 100; diff --git a/src/org/torproject/descriptor/impl/BridgeExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/BridgeExtraInfoDescriptorImpl.java index daacfba..15d40d8 100644 --- a/src/org/torproject/descriptor/impl/BridgeExtraInfoDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/BridgeExtraInfoDescriptorImpl.java @@ -15,8 +15,7 @@ public class BridgeExtraInfoDescriptorImpl protected static List<ExtraInfoDescriptor> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<ExtraInfoDescriptor> parsedDescriptors = - new ArrayList<ExtraInfoDescriptor>(); + List<ExtraInfoDescriptor> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "extra-info "); diff --git a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java index bddf5ab..d5e6d8f 100644 --- a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java +++ b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java @@ -82,7 +82,7 @@ public class BridgeNetworkStatusImpl extends NetworkStatusImpl + "' in bridge network status."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } diff --git a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java index 01dc7b0..06270bc 100644 --- a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java +++ b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java @@ -21,8 +21,7 @@ public class BridgePoolAssignmentImpl extends DescriptorImpl protected static List<BridgePoolAssignment> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<BridgePoolAssignment> parsedDescriptors = - new ArrayList<BridgePoolAssignment>(); + List<BridgePoolAssignment> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "bridge-pool-assignment "); @@ -40,7 +39,7 @@ public class BridgePoolAssignmentImpl extends DescriptorImpl throws DescriptorParseException { super(descriptorBytes, failUnrecognizedDescriptorLines, false); this.parseDescriptorBytes(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList( new String[] { "bridge-pool-assignment" })); this.checkExactlyOnceKeywords(exactlyOnceKeywords); this.checkFirstKeyword("bridge-pool-assignment"); @@ -90,10 +89,9 @@ public class BridgePoolAssignmentImpl extends DescriptorImpl return this.publishedMillis; } - private SortedMap<String, String> entries = - new TreeMap<String, String>(); + private SortedMap<String, String> entries = new TreeMap<>(); public SortedMap<String, String> getEntries() { - return new TreeMap<String, String>(this.entries); + return new TreeMap<>(this.entries); } } diff --git a/src/org/torproject/descriptor/impl/BridgeServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/BridgeServerDescriptorImpl.java index 0dec458..eb2b933 100644 --- a/src/org/torproject/descriptor/impl/BridgeServerDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/BridgeServerDescriptorImpl.java @@ -15,8 +15,7 @@ public class BridgeServerDescriptorImpl extends ServerDescriptorImpl protected static List<ServerDescriptor> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<ServerDescriptor> parsedDescriptors = - new ArrayList<ServerDescriptor>(); + List<ServerDescriptor> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "router "); diff --git a/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java b/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java index 8b5f2ca..49c7995 100644 --- a/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java +++ b/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java @@ -49,8 +49,8 @@ public class DescriptorCollectorImpl implements DescriptorCollector { this.statLocalDirectory(localDirectory); SortedMap<String, String> fetchedDirectoryListings = this.fetchRemoteDirectories(collecTorBaseUrl, remoteDirectories); - SortedSet<String> parsedDirectories = new TreeSet<String>(); - SortedMap<String, Long> remoteFiles = new TreeMap<String, Long>(); + SortedSet<String> parsedDirectories = new TreeSet<>(); + SortedMap<String, Long> remoteFiles = new TreeMap<>(); for (Map.Entry<String, String> e : fetchedDirectoryListings.entrySet()) { String remoteDirectory = e.getKey(); @@ -73,11 +73,11 @@ public class DescriptorCollectorImpl implements DescriptorCollector { SortedMap<String, Long> statLocalDirectory( File localDirectory) { - SortedMap<String, Long> localFiles = new TreeMap<String, Long>(); + SortedMap<String, Long> localFiles = new TreeMap<>(); if (!localDirectory.exists()) { return localFiles; } - Stack<File> files = new Stack<File>(); + Stack<File> files = new Stack<>(); files.add(localDirectory); while (!files.isEmpty()) { File file = files.pop(); @@ -94,8 +94,7 @@ public class DescriptorCollectorImpl implements DescriptorCollector { SortedMap<String, String> fetchRemoteDirectories( String collecTorBaseUrl, String[] remoteDirectories) { - SortedMap<String, String> fetchedDirectoryListings = - new TreeMap<String, String>(); + SortedMap<String, String> fetchedDirectoryListings = new TreeMap<>(); for (String remoteDirectory : remoteDirectories) { String remoteDirectoryWithSlashAtBeginAndEnd = (remoteDirectory.startsWith("/") ? "" : "/") + remoteDirectory @@ -145,7 +144,7 @@ public class DescriptorCollectorImpl implements DescriptorCollector { SortedMap<String, Long> parseDirectoryListing( String remoteDirectory, String directoryListing) { - SortedMap<String, Long> remoteFiles = new TreeMap<String, Long>(); + SortedMap<String, Long> remoteFiles = new TreeMap<>(); DateFormat dateTimeFormat = ParseHelper.getDateFormat( "dd-MMM-yyyy HH:mm"); try { diff --git a/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java index 490b1ac..aaac8f8 100644 --- a/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java +++ b/src/org/torproject/descriptor/impl/DescriptorDownloaderImpl.java @@ -17,7 +17,7 @@ public class DescriptorDownloaderImpl private boolean hasStartedDownloading = false; private SortedMap<String, DirectoryDownloader> directoryAuthorities = - new TreeMap<String, DirectoryDownloader>(); + new TreeMap<>(); public void addDirectoryAuthority(String nickname, String ip, int dirPort) { if (this.hasStartedDownloading) { @@ -31,7 +31,7 @@ public class DescriptorDownloaderImpl } private SortedMap<String, DirectoryDownloader> directoryMirrors = - new TreeMap<String, DirectoryDownloader>(); + new TreeMap<>(); public void addDirectoryMirror(String nickname, String ip, int dirPort) { if (this.hasStartedDownloading) { @@ -99,7 +99,7 @@ public class DescriptorDownloaderImpl this.includeCurrentReferencedVotes = true; } - private Set<String> downloadVotes = new HashSet<String>(); + private Set<String> downloadVotes = new HashSet<>(); public void setIncludeCurrentVote(String fingerprint) { if (this.hasStartedDownloading) { throw new IllegalStateException("Reconfiguration is not permitted " diff --git a/src/org/torproject/descriptor/impl/DescriptorFileImpl.java b/src/org/torproject/descriptor/impl/DescriptorFileImpl.java index 440426d..b683e7f 100644 --- a/src/org/torproject/descriptor/impl/DescriptorFileImpl.java +++ b/src/org/torproject/descriptor/impl/DescriptorFileImpl.java @@ -57,7 +57,7 @@ public class DescriptorFileImpl implements DescriptorFile { } public List<Descriptor> getDescriptors() { return this.descriptors == null ? new ArrayList<Descriptor>() : - new ArrayList<Descriptor>(this.descriptors); + new ArrayList<>(this.descriptors); } private Exception exception; diff --git a/src/org/torproject/descriptor/impl/DescriptorImpl.java b/src/org/torproject/descriptor/impl/DescriptorImpl.java index 4e639a4..e7a3f0e 100644 --- a/src/org/torproject/descriptor/impl/DescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/DescriptorImpl.java @@ -19,7 +19,7 @@ public abstract class DescriptorImpl implements Descriptor { byte[] rawDescriptorBytes, String fileName, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<Descriptor> parsedDescriptors = new ArrayList<Descriptor>(); + List<Descriptor> parsedDescriptors = new ArrayList<>(); if (rawDescriptorBytes == null) { return parsedDescriptors; } @@ -114,7 +114,7 @@ public abstract class DescriptorImpl implements Descriptor { protected static List<byte[]> splitRawDescriptorBytes( byte[] rawDescriptorBytes, String startToken) { - List<byte[]> rawDescriptors = new ArrayList<byte[]>(); + List<byte[]> rawDescriptors = new ArrayList<>(); String splitToken = "\n" + startToken; String ascii; try { @@ -168,7 +168,7 @@ public abstract class DescriptorImpl implements Descriptor { protected List<String> unrecognizedLines; public List<String> getUnrecognizedLines() { return this.unrecognizedLines == null ? new ArrayList<String>() : - new ArrayList<String>(this.unrecognizedLines); + new ArrayList<>(this.unrecognizedLines); } protected DescriptorImpl(byte[] rawDescriptorBytes, @@ -182,7 +182,7 @@ public abstract class DescriptorImpl implements Descriptor { } /* Parse annotation lines from the descriptor bytes. */ - private List<String> annotations = new ArrayList<String>(); + private List<String> annotations = new ArrayList<>(); private void cutOffAnnotations(byte[] rawDescriptorBytes) throws DescriptorParseException { String ascii = new String(rawDescriptorBytes); @@ -206,13 +206,12 @@ public abstract class DescriptorImpl implements Descriptor { } } public List<String> getAnnotations() { - return new ArrayList<String>(this.annotations); + return new ArrayList<>(this.annotations); } /* Count parsed keywords for consistency checks by subclasses. */ private String firstKeyword, lastKeyword; - private Map<String, Integer> parsedKeywords = - new HashMap<String, Integer>(); + private Map<String, Integer> parsedKeywords = new HashMap<>(); private void countKeywords(byte[] rawDescriptorBytes, boolean blankLinesAllowed) throws DescriptorParseException { if (rawDescriptorBytes.length == 0) { diff --git a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java index e47c2a7..454c526 100644 --- a/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java +++ b/src/org/torproject/descriptor/impl/DescriptorReaderImpl.java @@ -34,7 +34,7 @@ public class DescriptorReaderImpl implements DescriptorReader { private boolean hasStartedReading = false; - private List<File> directories = new ArrayList<File>(); + private List<File> directories = new ArrayList<>(); public void addDirectory(File directory) { if (this.hasStartedReading) { throw new IllegalStateException("Reconfiguration is not permitted " @@ -43,7 +43,7 @@ public class DescriptorReaderImpl implements DescriptorReader { this.directories.add(directory); } - private List<File> tarballs = new ArrayList<File>(); + private List<File> tarballs = new ArrayList<>(); public void addTarball(File tarball) { if (this.hasStartedReading) { throw new IllegalStateException("Reconfiguration is not permitted " @@ -75,7 +75,7 @@ public class DescriptorReaderImpl implements DescriptorReader { throw new IllegalStateException("Operation is not permitted before " + "finishing to read."); } - return new TreeMap<String, Long>(this.reader.excludedFilesAfter); + return new TreeMap<>(this.reader.excludedFilesAfter); } public SortedMap<String, Long> getParsedFiles() { @@ -83,7 +83,7 @@ public class DescriptorReaderImpl implements DescriptorReader { throw new IllegalStateException("Operation is not permitted before " + "finishing to read."); } - return new TreeMap<String, Long>(this.reader.parsedFilesAfter); + return new TreeMap<>(this.reader.parsedFilesAfter); } private boolean failUnrecognizedDescriptorLines = false; @@ -128,10 +128,9 @@ public class DescriptorReaderImpl implements DescriptorReader { private List<File> tarballs; private BlockingIteratorImpl<DescriptorFile> descriptorQueue; private File historyFile; - private SortedMap<String, Long> - excludedFilesBefore = new TreeMap<String, Long>(), - excludedFilesAfter = new TreeMap<String, Long>(), - parsedFilesAfter = new TreeMap<String, Long>(); + private SortedMap<String, Long> excludedFilesBefore = new TreeMap<>(), + excludedFilesAfter = new TreeMap<>(), + parsedFilesAfter = new TreeMap<>(); private DescriptorParser descriptorParser; private boolean hasFinishedReading = false; private DescriptorReaderRunnable(List<File> directories, @@ -205,7 +204,7 @@ public class DescriptorReaderImpl implements DescriptorReader { } BufferedWriter bw = new BufferedWriter(new FileWriter( this.historyFile)); - SortedMap<String, Long> newHistory = new TreeMap<String, Long>(); + SortedMap<String, Long> newHistory = new TreeMap<>(); newHistory.putAll(this.excludedFilesAfter); newHistory.putAll(this.parsedFilesAfter); for (Map.Entry<String, Long> e : newHistory.entrySet()) { @@ -224,7 +223,7 @@ public class DescriptorReaderImpl implements DescriptorReader { if (!directory.exists() || !directory.isDirectory()) { continue; } - Stack<File> files = new Stack<File>(); + Stack<File> files = new Stack<>(); files.add(directory); boolean abortReading = false; while (!abortReading && !files.isEmpty()) { @@ -265,7 +264,7 @@ public class DescriptorReaderImpl implements DescriptorReader { } } private void readTarballs() { - List<File> files = new ArrayList<File>(this.tarballs); + List<File> files = new ArrayList<>(this.tarballs); boolean abortReading = false; while (!abortReading && !files.isEmpty()) { File tarball = files.remove(0); diff --git a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java index 5b65789..3a59d5b 100644 --- a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java +++ b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java @@ -39,10 +39,10 @@ public class DirSourceEntryImpl implements DirSourceEntry { private SortedSet<String> exactlyOnceKeywords, atMostOnceKeywords; private void initializeKeywords() { - this.exactlyOnceKeywords = new TreeSet<String>(); + this.exactlyOnceKeywords = new TreeSet<>(); this.exactlyOnceKeywords.add("dir-source"); this.exactlyOnceKeywords.add("vote-digest"); - this.atMostOnceKeywords = new TreeSet<String>(); + this.atMostOnceKeywords = new TreeSet<>(); this.atMostOnceKeywords.add("contact"); } @@ -96,7 +96,7 @@ public class DirSourceEntryImpl implements DirSourceEntry { + line + "' in dir-source entry."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } diff --git a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java index 4a2f39c..152ffeb 100644 --- a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java +++ b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java @@ -25,8 +25,7 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl protected static List<DirectoryKeyCertificate> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<DirectoryKeyCertificate> parsedDescriptors = - new ArrayList<DirectoryKeyCertificate>(); + List<DirectoryKeyCertificate> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DirectoryKeyCertificateImpl.splitRawDescriptorBytes( descriptorsBytes, "dir-key-certificate-version "); @@ -45,12 +44,12 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl super(rawDescriptorBytes, failUnrecognizedDescriptorLines, false); this.parseDescriptorBytes(); this.calculateDigest(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "dir-key-certificate-version,fingerprint,dir-identity-key," + "dir-key-published,dir-key-expires,dir-signing-key," + "dir-key-certification").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "dir-address,dir-key-crosscert").split(","))); this.checkAtMostOnceKeywords(atMostOnceKeywords); this.checkFirstKeyword("dir-key-certificate-version"); @@ -117,7 +116,7 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl + line + "' in directory key certificate."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } diff --git a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java index 4e56006..27e9cc9 100644 --- a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java +++ b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java @@ -70,7 +70,7 @@ public class DirectorySignatureImpl implements DirectorySignature { + line + "' in dir-source entry."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } diff --git a/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java b/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java index 067c38c..e95f9da 100644 --- a/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java +++ b/src/org/torproject/descriptor/impl/DownloadCoordinatorImpl.java @@ -20,7 +20,7 @@ import org.torproject.descriptor.RelayNetworkStatusConsensus; public class DownloadCoordinatorImpl implements DownloadCoordinator { private BlockingIteratorImpl<DescriptorRequest> descriptorQueue = - new BlockingIteratorImpl<DescriptorRequest>(); + new BlockingIteratorImpl<>(); protected Iterator<DescriptorRequest> getDescriptorQueue() { return this.descriptorQueue; } @@ -45,7 +45,7 @@ public class DownloadCoordinatorImpl implements DownloadCoordinator { long globalTimeoutMillis, boolean failUnrecognizedDescriptorLines) { this.directoryAuthorities = directoryAuthorities; this.directoryMirrors = directoryMirrors; - this.runningDirectories = new TreeSet<String>(); + this.runningDirectories = new TreeSet<>(); this.runningDirectories.addAll(directoryAuthorities.keySet()); this.runningDirectories.addAll(directoryMirrors.keySet()); this.missingConsensus = downloadConsensus; @@ -120,24 +120,22 @@ public class DownloadCoordinatorImpl implements DownloadCoordinator { /* Which directories are currently attempting to download the * consensus? */ - private Set<String> requestingConsensuses = new HashSet<String>(); + private Set<String> requestingConsensuses = new HashSet<>(); /* Which directories have attempted to download the consensus so far, * including those directories that are currently attempting it? */ - private Set<String> requestedConsensuses = new HashSet<String>(); + private Set<String> requestedConsensuses = new HashSet<>(); /* Which votes are we currently missing? */ - private Set<String> missingVotes = new HashSet<String>(); + private Set<String> missingVotes = new HashSet<>(); /* Which vote (map value) is a given directory (map key) currently * attempting to download? */ - private Map<String, String> requestingVotes = - new HashMap<String, String>(); + private Map<String, String> requestingVotes = new HashMap<>(); /* Which votes (map value) has a given directory (map key) attempted or * is currently attempting to download? */ - private Map<String, Set<String>> requestedVotes = - new HashMap<String, Set<String>>(); + private Map<String, Set<String>> requestedVotes = new HashMap<>(); private boolean hasFinishedDownloading = false; diff --git a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java index e899bcf..6d00bf4 100644 --- a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java +++ b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java @@ -68,7 +68,7 @@ public class ExitListEntryImpl implements ExitListEntry, ExitList.Entry { private SortedSet<String> keywordCountingSet; private void initializeKeywords() { - this.keywordCountingSet = new TreeSet<String>(); + this.keywordCountingSet = new TreeSet<>(); this.keywordCountingSet.add("ExitNode"); this.keywordCountingSet.add("Published"); this.keywordCountingSet.add("LastStatus"); diff --git a/src/org/torproject/descriptor/impl/ExitListImpl.java b/src/org/torproject/descriptor/impl/ExitListImpl.java index 730217e..33003df 100644 --- a/src/org/torproject/descriptor/impl/ExitListImpl.java +++ b/src/org/torproject/descriptor/impl/ExitListImpl.java @@ -94,7 +94,7 @@ public class ExitListImpl extends DescriptorImpl implements ExitList { + line + "' in exit list."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -114,7 +114,7 @@ public class ExitListImpl extends DescriptorImpl implements ExitList { getAndClearUnrecognizedLines(); if (unrecognizedExitListEntryLines != null) { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(unrecognizedExitListEntryLines); } @@ -133,7 +133,7 @@ public class ExitListImpl extends DescriptorImpl implements ExitList { private Set<ExitList.Entry> exitListEntries = new HashSet<>(); public Set<ExitList.Entry> getEntries() { - return new HashSet<ExitList.Entry>(this.exitListEntries); + return new HashSet<>(this.exitListEntries); } } diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java index ef0c82c..ff8df51 100644 --- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java @@ -34,27 +34,27 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl this.parseDescriptorBytes(); this.calculateDigest(); this.calculateDigestSha256(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "extra-info,published").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> dirreqStatsKeywords = new HashSet<String>(Arrays.asList(( + Set<String> dirreqStatsKeywords = new HashSet<>(Arrays.asList(( "dirreq-stats-end,dirreq-v2-ips,dirreq-v3-ips,dirreq-v2-reqs," + "dirreq-v3-reqs,dirreq-v2-share,dirreq-v3-share,dirreq-v2-resp," + "dirreq-v3-resp,dirreq-v2-direct-dl,dirreq-v3-direct-dl," + "dirreq-v2-tunneled-dl,dirreq-v3-tunneled-dl,").split(","))); - Set<String> entryStatsKeywords = new HashSet<String>(Arrays.asList( + Set<String> entryStatsKeywords = new HashSet<>(Arrays.asList( "entry-stats-end,entry-ips".split(","))); - Set<String> cellStatsKeywords = new HashSet<String>(Arrays.asList(( + Set<String> cellStatsKeywords = new HashSet<>(Arrays.asList(( "cell-stats-end,cell-processed-cells,cell-queued-cells," + "cell-time-in-queue,cell-circuits-per-decile").split(","))); - Set<String> connBiDirectStatsKeywords = new HashSet<String>( + Set<String> connBiDirectStatsKeywords = new HashSet<>( Arrays.asList("conn-bi-direct".split(","))); - Set<String> exitStatsKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exitStatsKeywords = new HashSet<>(Arrays.asList(( "exit-stats-end,exit-kibibytes-written,exit-kibibytes-read," + "exit-streams-opened").split(","))); - Set<String> bridgeStatsKeywords = new HashSet<String>(Arrays.asList( + Set<String> bridgeStatsKeywords = new HashSet<>(Arrays.asList( "bridge-stats-end,bridge-stats-ips".split(","))); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "identity-ed25519,master-key-ed25519,read-history,write-history," + "dirreq-read-history,dirreq-write-history,geoip-db-digest," + "router-sig-ed25519,router-signature,router-digest-sha256," @@ -189,7 +189,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl } else if (keyword.equals("router-digest-sha256")) { this.parseRouterDigestSha256Line(line, lineNoOpt, partsNoOpt); } else if (line.startsWith("-----BEGIN")) { - cryptoLines = new ArrayList<String>(); + cryptoLines = new ArrayList<>(); cryptoLines.add(line); } else if (line.startsWith("-----END")) { cryptoLines.add(line); @@ -208,7 +208,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl + "block '" + cryptoString + "' in extra-info descriptor."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(cryptoLines); } @@ -223,7 +223,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl + line + "' in extra-info descriptor."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -1047,19 +1047,19 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl private SortedMap<String, Long> exitKibibytesWritten; public SortedMap<String, Long> getExitKibibytesWritten() { return this.exitKibibytesWritten == null ? null : - new TreeMap<String, Long>(this.exitKibibytesWritten); + new TreeMap<>(this.exitKibibytesWritten); } private SortedMap<String, Long> exitKibibytesRead; public SortedMap<String, Long> getExitKibibytesRead() { return this.exitKibibytesRead == null ? null : - new TreeMap<String, Long>(this.exitKibibytesRead); + new TreeMap<>(this.exitKibibytesRead); } private SortedMap<String, Long> exitStreamsOpened; public SortedMap<String, Long> getExitStreamsOpened() { return this.exitStreamsOpened == null ? null : - new TreeMap<String, Long>(this.exitStreamsOpened); + new TreeMap<>(this.exitStreamsOpened); } private long geoipStartTimeMillis = -1L; @@ -1101,9 +1101,9 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl this.bridgeIpTransports); } - private List<String> transports = new ArrayList<String>(); + private List<String> transports = new ArrayList<>(); public List<String> getTransports() { - return new ArrayList<String>(this.transports); + return new ArrayList<>(this.transports); } private long hidservStatsEndMillis = -1L; diff --git a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java index 1987659..3e7f466 100644 --- a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java @@ -24,8 +24,7 @@ public class MicrodescriptorImpl extends DescriptorImpl protected static List<Microdescriptor> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<Microdescriptor> parsedDescriptors = - new ArrayList<Microdescriptor>(); + List<Microdescriptor> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "onion-key\n"); @@ -44,10 +43,10 @@ public class MicrodescriptorImpl extends DescriptorImpl super(descriptorBytes, failUnrecognizedDescriptorLines, false); this.parseDescriptorBytes(); this.calculateDigest(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList( "onion-key".split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "ntor-onion-key,family,p,p6,id").split(","))); this.checkAtMostOnceKeywords(atMostOnceKeywords); this.checkFirstKeyword("onion-key"); @@ -105,7 +104,7 @@ public class MicrodescriptorImpl extends DescriptorImpl + line + "' in microdescriptor."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -253,9 +252,9 @@ public class MicrodescriptorImpl extends DescriptorImpl return this.ntorOnionKey; } - private List<String> orAddresses = new ArrayList<String>(); + private List<String> orAddresses = new ArrayList<>(); public List<String> getOrAddresses() { - return new ArrayList<String>(this.orAddresses); + return new ArrayList<>(this.orAddresses); } private String[] familyEntries; diff --git a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java index 94575c6..4f2b69b 100644 --- a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java +++ b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java @@ -48,7 +48,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { private SortedSet<String> atMostOnceKeywords; private void initializeKeywords() { - this.atMostOnceKeywords = new TreeSet<String>(); + this.atMostOnceKeywords = new TreeSet<>(); this.atMostOnceKeywords.add("s"); this.atMostOnceKeywords.add("v"); this.atMostOnceKeywords.add("w"); @@ -98,7 +98,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { + "' in status entry."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -142,10 +142,8 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { this.orAddresses.add(parts[1]); } - private static Map<String, Integer> flagIndexes = - new HashMap<String, Integer>(); - private static Map<Integer, String> flagStrings = - new HashMap<Integer, String>(); + private static Map<String, Integer> flagIndexes = new HashMap<>(); + private static Map<Integer, String> flagStrings = new HashMap<>(); private void parseSLine(String line, String[] parts) throws DescriptorParseException { @@ -226,7 +224,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { private void parseMLine(String line, String[] parts) throws DescriptorParseException { if (this.microdescriptorDigests == null) { - this.microdescriptorDigests = new HashSet<String>(); + this.microdescriptorDigests = new HashSet<>(); } if (parts.length == 2) { this.microdescriptorDigests.add( @@ -293,17 +291,17 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { private Set<String> microdescriptorDigests; public Set<String> getMicrodescriptorDigests() { return this.microdescriptorDigests == null ? null : - new HashSet<String>(this.microdescriptorDigests); + new HashSet<>(this.microdescriptorDigests); } - private List<String> orAddresses = new ArrayList<String>(); + private List<String> orAddresses = new ArrayList<>(); public List<String> getOrAddresses() { - return new ArrayList<String>(this.orAddresses); + return new ArrayList<>(this.orAddresses); } private BitSet flags; 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)) { diff --git a/src/org/torproject/descriptor/impl/NetworkStatusImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusImpl.java index 9f92b47..a9c2483 100644 --- a/src/org/torproject/descriptor/impl/NetworkStatusImpl.java +++ b/src/org/torproject/descriptor/impl/NetworkStatusImpl.java @@ -134,7 +134,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { private List<byte[]> splitByKeyword(String descriptorString, String keyword, int start, int end) { - List<byte[]> splitParts = new ArrayList<byte[]>(); + List<byte[]> splitParts = new ArrayList<>(); int from = start; while (from < end) { int to = descriptorString.indexOf("\n" + keyword + " ", from); @@ -168,7 +168,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { getAndClearUnrecognizedLines(); if (unrecognizedDirSourceLines != null) { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(unrecognizedDirSourceLines); } @@ -203,7 +203,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { getAndClearUnrecognizedLines(); if (unrecognizedStatusEntryLines != null) { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(unrecognizedStatusEntryLines); } @@ -215,8 +215,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { protected void parseDirectorySignature(byte[] directorySignatureBytes) throws DescriptorParseException { if (this.directorySignatures == null) { - this.directorySignatures = new TreeMap<String, - DirectorySignature>(); + this.directorySignatures = new TreeMap<>(); } DirectorySignatureImpl signature = new DirectorySignatureImpl( directorySignatureBytes, failUnrecognizedDescriptorLines); @@ -225,22 +224,22 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { getAndClearUnrecognizedLines(); if (unrecognizedStatusEntryLines != null) { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(unrecognizedStatusEntryLines); } } protected SortedMap<String, DirSourceEntry> dirSourceEntries = - new TreeMap<String, DirSourceEntry>(); + new TreeMap<>(); public SortedMap<String, DirSourceEntry> getDirSourceEntries() { - return new TreeMap<String, DirSourceEntry>(this.dirSourceEntries); + return new TreeMap<>(this.dirSourceEntries); } protected SortedMap<String, NetworkStatusEntry> statusEntries = - new TreeMap<String, NetworkStatusEntry>(); + new TreeMap<>(); public SortedMap<String, NetworkStatusEntry> getStatusEntries() { - return new TreeMap<String, NetworkStatusEntry>(this.statusEntries); + return new TreeMap<>(this.statusEntries); } public boolean containsStatusEntry(String fingerprint) { return this.statusEntries.containsKey(fingerprint); @@ -252,7 +251,7 @@ public abstract class NetworkStatusImpl extends DescriptorImpl { protected SortedMap<String, DirectorySignature> directorySignatures; public SortedMap<String, DirectorySignature> getDirectorySignatures() { return this.directorySignatures == null ? null : - new TreeMap<String, DirectorySignature>(this.directorySignatures); + new TreeMap<>(this.directorySignatures); } } diff --git a/src/org/torproject/descriptor/impl/ParseHelper.java b/src/org/torproject/descriptor/impl/ParseHelper.java index 15de5ee..43a44d1 100644 --- a/src/org/torproject/descriptor/impl/ParseHelper.java +++ b/src/org/torproject/descriptor/impl/ParseHelper.java @@ -146,7 +146,7 @@ public class ParseHelper { return super.get(); } protected Map<String, DateFormat> initialValue() { - return new HashMap<String, DateFormat>(); + return new HashMap<>(); } public void remove() { super.remove(); @@ -221,7 +221,7 @@ public class ParseHelper { public static SortedMap<String, String> parseKeyValueStringPairs( String line, String[] parts, int startIndex, String separatorString) throws DescriptorParseException { - SortedMap<String, String> result = new TreeMap<String, String>(); + SortedMap<String, String> result = new TreeMap<>(); for (int i = startIndex; i < parts.length; i++) { String pair = parts[i]; String[] pairParts = pair.split(separatorString); @@ -237,7 +237,7 @@ public class ParseHelper { public static SortedMap<String, Integer> parseKeyValueIntegerPairs( String line, String[] parts, int startIndex, String separatorString) throws DescriptorParseException { - SortedMap<String, Integer> result = new TreeMap<String, Integer>(); + SortedMap<String, Integer> result = new TreeMap<>(); SortedMap<String, String> keyValueStringPairs = ParseHelper.parseKeyValueStringPairs(line, parts, startIndex, separatorString); @@ -292,8 +292,7 @@ public class ParseHelper { } private static Map<Integer, Pattern> - commaSeparatedKeyValueListPatterns = - new HashMap<Integer, Pattern>(); + commaSeparatedKeyValueListPatterns = new HashMap<>(); public static String parseCommaSeparatedKeyIntegerValueList( String line, String[] partsNoOpt, int index, int keyLength) throws DescriptorParseException { @@ -331,7 +330,7 @@ public class ParseHelper { convertCommaSeparatedKeyIntegerValueList(String validatedString) { SortedMap<String, Integer> result = null; if (validatedString != null) { - result = new TreeMap<String, Integer>(); + result = new TreeMap<>(); if (validatedString.contains("=")) { for (String listElement : validatedString.split(",", -1)) { String[] keyAndValue = listElement.split("="); @@ -346,7 +345,7 @@ public class ParseHelper { parseCommaSeparatedKeyLongValueList(String line, String[] partsNoOpt, int index, int keyLength) throws DescriptorParseException { - SortedMap<String, Long> result = new TreeMap<String, Long>(); + SortedMap<String, Long> result = new TreeMap<>(); if (partsNoOpt.length < index) { throw new DescriptorParseException("Line '" + line + "' does not " + "contain a key-value list at index " + index + "."); diff --git a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java index e613c88..0b82328 100644 --- a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java +++ b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java @@ -27,8 +27,7 @@ public class RelayDirectoryImpl extends DescriptorImpl protected static List<RelayDirectory> parseDirectories( byte[] directoriesBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<RelayDirectory> parsedDirectories = - new ArrayList<RelayDirectory>(); + List<RelayDirectory> parsedDirectories = new ArrayList<>(); List<byte[]> splitDirectoriesBytes = DescriptorImpl.splitRawDescriptorBytes(directoriesBytes, "signed-directory\n"); @@ -47,11 +46,11 @@ public class RelayDirectoryImpl extends DescriptorImpl super(directoryBytes, failUnrecognizedDescriptorLines, true); this.splitAndParseParts(rawDescriptorBytes); this.calculateDigest(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "signed-directory,recommended-software," + "directory-signature").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList( "dir-signing-key,running-routers,router-status".split(","))); this.checkAtMostOnceKeywords(atMostOnceKeywords); this.checkFirstKeyword("signed-directory"); @@ -161,7 +160,7 @@ public class RelayDirectoryImpl extends DescriptorImpl private List<byte[]> splitByKeyword(String descriptorString, String keyword, int start, int end) { - List<byte[]> splitParts = new ArrayList<byte[]>(); + List<byte[]> splitParts = new ArrayList<>(); int from = start; while (from < end) { int to = descriptorString.indexOf("\n" + keyword + " ", from); @@ -244,7 +243,7 @@ public class RelayDirectoryImpl extends DescriptorImpl + line + "' in v1 directory."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -329,7 +328,7 @@ public class RelayDirectoryImpl extends DescriptorImpl + "' in v2 network status."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -374,7 +373,7 @@ public class RelayDirectoryImpl extends DescriptorImpl private void parseRecommendedSoftwareLine(String line, String lineNoOpt, String[] partsNoOpt) throws DescriptorParseException { - List<String> result = new ArrayList<String>(); + List<String> result = new ArrayList<>(); if (partsNoOpt.length > 2) { throw new DescriptorParseException("Illegal versions line '" + line + "'."); @@ -485,7 +484,7 @@ public class RelayDirectoryImpl extends DescriptorImpl private List<String> recommendedSoftware; public List<String> getRecommendedSoftware() { return this.recommendedSoftware == null ? null : - new ArrayList<String>(this.recommendedSoftware); + new ArrayList<>(this.recommendedSoftware); } private String directorySignature; @@ -493,22 +492,20 @@ public class RelayDirectoryImpl extends DescriptorImpl return this.directorySignature; } - private List<RouterStatusEntry> statusEntries = - new ArrayList<RouterStatusEntry>(); + private List<RouterStatusEntry> statusEntries = new ArrayList<>(); public List<RouterStatusEntry> getRouterStatusEntries() { - return new ArrayList<RouterStatusEntry>(this.statusEntries); + return new ArrayList<>(this.statusEntries); } - private List<ServerDescriptor> serverDescriptors = - new ArrayList<ServerDescriptor>(); + private List<ServerDescriptor> serverDescriptors = new ArrayList<>(); public List<ServerDescriptor> getServerDescriptors() { - return new ArrayList<ServerDescriptor>(this.serverDescriptors); + return new ArrayList<>(this.serverDescriptors); } private List<Exception> serverDescriptorParseExceptions = - new ArrayList<Exception>(); + new ArrayList<>(); public List<Exception> getServerDescriptorParseExceptions() { - return new ArrayList<Exception>(this.serverDescriptorParseExceptions); + return new ArrayList<>(this.serverDescriptorParseExceptions); } private String nickname; diff --git a/src/org/torproject/descriptor/impl/RelayExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/RelayExtraInfoDescriptorImpl.java index 5ff0e04..73d4dfa 100644 --- a/src/org/torproject/descriptor/impl/RelayExtraInfoDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/RelayExtraInfoDescriptorImpl.java @@ -15,8 +15,7 @@ public class RelayExtraInfoDescriptorImpl protected static List<ExtraInfoDescriptor> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<ExtraInfoDescriptor> parsedDescriptors = - new ArrayList<ExtraInfoDescriptor>(); + List<ExtraInfoDescriptor> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "extra-info "); diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java index 0b3c53a..d92718c 100644 --- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java +++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java @@ -29,7 +29,7 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl byte[] consensusesBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { List<RelayNetworkStatusConsensus> parsedConsensuses = - new ArrayList<RelayNetworkStatusConsensus>(); + new ArrayList<>(); List<byte[]> splitConsensusBytes = DescriptorImpl.splitRawDescriptorBytes(consensusesBytes, "network-status-version 3"); @@ -46,11 +46,11 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { super(consensusBytes, failUnrecognizedDescriptorLines, true, false); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "vote-status,consensus-method,valid-after,fresh-until," + "valid-until,voting-delay,known-flags").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "client-versions,server-versions,params,directory-footer," + "bandwidth-weights").split(","))); this.checkAtMostOnceKeywords(atMostOnceKeywords); @@ -122,7 +122,7 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl + "' in consensus."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -140,7 +140,7 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl getAndClearUnrecognizedLines(); if (unrecognizedStatusEntryLines != null) { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(unrecognizedStatusEntryLines); } @@ -161,7 +161,7 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl + "' in consensus."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -341,19 +341,19 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl private String[] knownFlags; public SortedSet<String> getKnownFlags() { - return new TreeSet<String>(Arrays.asList(this.knownFlags)); + return new TreeSet<>(Arrays.asList(this.knownFlags)); } private SortedMap<String, Integer> consensusParams; public SortedMap<String, Integer> getConsensusParams() { return this.consensusParams == null ? null: - new TreeMap<String, Integer>(this.consensusParams); + new TreeMap<>(this.consensusParams); } private SortedMap<String, Integer> bandwidthWeights; public SortedMap<String, Integer> getBandwidthWeights() { return this.bandwidthWeights == null ? null : - new TreeMap<String, Integer>(this.bandwidthWeights); + new TreeMap<>(this.bandwidthWeights); } } diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java index 6faeee0..c2735e7 100644 --- a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java +++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java @@ -27,8 +27,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl protected static List<RelayNetworkStatus> parseStatuses( byte[] statusesBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<RelayNetworkStatus> parsedStatuses = - new ArrayList<RelayNetworkStatus>(); + List<RelayNetworkStatus> parsedStatuses = new ArrayList<>(); List<byte[]> splitStatusBytes = DescriptorImpl.splitRawDescriptorBytes(statusesBytes, "network-status-version 2"); @@ -44,11 +43,11 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { super(statusBytes, failUnrecognizedDescriptorLines, false, true); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "network-status-version,dir-source,fingerprint,contact," + "dir-signing-key,published").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList( "dir-options,client-versions,server-versions".split(","))); this.checkAtMostOnceKeywords(atMostOnceKeywords); this.checkFirstKeyword("network-status-version"); @@ -138,7 +137,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl + "' in v2 network status."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -185,7 +184,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl + "' in v2 network status."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -336,7 +335,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl private String[] dirOptions; public SortedSet<String> getDirOptions() { - return new TreeSet<String>(Arrays.asList(this.dirOptions)); + return new TreeSet<>(Arrays.asList(this.dirOptions)); } private String nickname; diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java index 410c2f1..b8f0412 100644 --- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java +++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java @@ -24,8 +24,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl protected static List<RelayNetworkStatusVote> parseVotes( byte[] votesBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<RelayNetworkStatusVote> parsedVotes = - new ArrayList<RelayNetworkStatusVote>(); + List<RelayNetworkStatusVote> parsedVotes = new ArrayList<>(); List<byte[]> splitVotesBytes = DescriptorImpl.splitRawDescriptorBytes(votesBytes, "network-status-version 3"); @@ -42,14 +41,14 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { super(voteBytes, failUnrecognizedDescriptorLines, false, false); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList(( "vote-status,consensus-methods,published,valid-after,fresh-until," + "valid-until,voting-delay,known-flags,dir-source," + "dir-key-certificate-version,fingerprint,dir-key-published," + "dir-key-expires,dir-identity-key,dir-signing-key," + "dir-key-certification,directory-signature").split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "client-versions,server-versions,flag-thresholds,params,contact," + "legacy-key,dir-key-crosscert,dir-address,directory-footer"). split(","))); @@ -136,7 +135,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl + line + "' in vote."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -385,7 +384,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl + line + "' in vote."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -502,7 +501,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl private String[] knownFlags; public SortedSet<String> getKnownFlags() { - return new TreeSet<String>(Arrays.asList(this.knownFlags)); + return new TreeSet<>(Arrays.asList(this.knownFlags)); } private long stableUptime; @@ -553,7 +552,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl private SortedMap<String, Integer> consensusParams; public SortedMap<String, Integer> getConsensusParams() { return this.consensusParams == null ? null: - new TreeMap<String, Integer>(this.consensusParams); + new TreeMap<>(this.consensusParams); } } diff --git a/src/org/torproject/descriptor/impl/RelayServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/RelayServerDescriptorImpl.java index 174c541..4957072 100644 --- a/src/org/torproject/descriptor/impl/RelayServerDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/RelayServerDescriptorImpl.java @@ -15,8 +15,7 @@ public class RelayServerDescriptorImpl extends ServerDescriptorImpl protected static List<ServerDescriptor> parseDescriptors( byte[] descriptorsBytes, boolean failUnrecognizedDescriptorLines) throws DescriptorParseException { - List<ServerDescriptor> parsedDescriptors = - new ArrayList<ServerDescriptor>(); + List<ServerDescriptor> parsedDescriptors = new ArrayList<>(); List<byte[]> splitDescriptorsBytes = DescriptorImpl.splitRawDescriptorBytes(descriptorsBytes, "router "); diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java index 1484866..ddca784 100644 --- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java +++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java @@ -29,10 +29,10 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl this.parseDescriptorBytes(); this.calculateDigest(); this.calculateDigestSha256(); - Set<String> exactlyOnceKeywords = new HashSet<String>(Arrays.asList( + Set<String> exactlyOnceKeywords = new HashSet<>(Arrays.asList( "router,bandwidth,published".split(","))); this.checkExactlyOnceKeywords(exactlyOnceKeywords); - Set<String> atMostOnceKeywords = new HashSet<String>(Arrays.asList(( + Set<String> atMostOnceKeywords = new HashSet<>(Arrays.asList(( "identity-ed25519,master-key-ed25519,platform,fingerprint," + "hibernating,uptime,contact,family,read-history,write-history," + "eventdns,caches-extra-info,extra-info-digest," @@ -138,7 +138,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl this.parseNtorOnionKeyCrosscert(line, lineNoOpt, partsNoOpt); nextCrypto = "ntor-onion-key-crosscert"; } else if (line.startsWith("-----BEGIN")) { - cryptoLines = new ArrayList<String>(); + cryptoLines = new ArrayList<>(); cryptoLines.add(line); } else if (line.startsWith("-----END")) { cryptoLines.add(line); @@ -165,7 +165,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl + "block '" + cryptoString + "' in server descriptor."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.addAll(cryptoLines); } @@ -180,7 +180,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl + line + "' in server descriptor."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -705,9 +705,9 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl return this.dirPort; } - private List<String> orAddresses = new ArrayList<String>(); + private List<String> orAddresses = new ArrayList<>(); public List<String> getOrAddresses() { - return new ArrayList<String>(this.orAddresses); + return new ArrayList<>(this.orAddresses); } private int bandwidthRate; @@ -760,9 +760,9 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl return this.signingKey; } - private List<String> exitPolicyLines = new ArrayList<String>(); + private List<String> exitPolicyLines = new ArrayList<>(); public List<String> getExitPolicyLines() { - return new ArrayList<String>(this.exitPolicyLines); + return new ArrayList<>(this.exitPolicyLines); } private String routerSignature; diff --git a/src/org/torproject/descriptor/impl/TorperfResultImpl.java b/src/org/torproject/descriptor/impl/TorperfResultImpl.java index 6da985f..aad8e32 100644 --- a/src/org/torproject/descriptor/impl/TorperfResultImpl.java +++ b/src/org/torproject/descriptor/impl/TorperfResultImpl.java @@ -24,7 +24,7 @@ public class TorperfResultImpl extends DescriptorImpl if (rawDescriptorBytes.length == 0) { throw new DescriptorParseException("Descriptor is empty."); } - List<Descriptor> parsedDescriptors = new ArrayList<Descriptor>(); + List<Descriptor> parsedDescriptors = new ArrayList<>(); String descriptorString = new String(rawDescriptorBytes); Scanner s = new Scanner(descriptorString).useDelimiter("\n"); String typeAnnotation = ""; @@ -130,7 +130,7 @@ public class TorperfResultImpl extends DescriptorImpl + "' in line '" + line + "'."); } else { if (this.unrecognizedLines == null) { - this.unrecognizedLines = new ArrayList<String>(); + this.unrecognizedLines = new ArrayList<>(); } this.unrecognizedLines.add(line); } @@ -138,8 +138,8 @@ public class TorperfResultImpl extends DescriptorImpl this.checkAllRequiredKeysParsed(line); } - private Set<String> parsedKeys = new HashSet<String>(); - private Set<String> requiredKeys = new HashSet<String>(Arrays.asList( + private Set<String> parsedKeys = new HashSet<>(); + private Set<String> requiredKeys = new HashSet<>(Arrays.asList( ("SOURCE,FILESIZE,START,SOCKET,CONNECT,NEGOTIATE,REQUEST,RESPONSE," + "DATAREQUEST,DATARESPONSE,DATACOMPLETE,WRITEBYTES,READBYTES"). split(","))); @@ -244,7 +244,7 @@ public class TorperfResultImpl extends DescriptorImpl } } - private Set<String> unparsedPercentiles = new HashSet<String>( + private Set<String> unparsedPercentiles = new HashSet<>( Arrays.asList("10,20,30,40,50,60,70,80,90".split(","))); private void parseDataPercentile(String value, String keyValue, String line) throws DescriptorParseException { @@ -431,7 +431,7 @@ public class TorperfResultImpl extends DescriptorImpl if (this.dataDeciles == null) { return null; } - SortedMap<Integer, Long> result = new TreeMap<Integer, Long>(); + SortedMap<Integer, Long> result = new TreeMap<>(); for (int i = 0; i < dataDeciles.length; i++) { if (dataDeciles[i] > 0L) { result.put(10 * (i + 1), dataDeciles[i]); diff --git a/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java b/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java index c8e95bf..d0e4cb7 100644 --- a/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java +++ b/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java @@ -51,7 +51,7 @@ public class BridgeNetworkStatusTest { return new BridgeNetworkStatusImpl(sb.buildStatus(), sb.fileName, true); } - private List<String> statusEntries = new ArrayList<String>(); + private List<String> statusEntries = new ArrayList<>(); private String unrecognizedHeaderLine = null; protected static BridgeNetworkStatus createWithUnrecognizedHeaderLine(String line, diff --git a/test/org/torproject/descriptor/impl/ConsensusBuilder.java b/test/org/torproject/descriptor/impl/ConsensusBuilder.java index 9d72e1e..470523d 100644 --- a/test/org/torproject/descriptor/impl/ConsensusBuilder.java +++ b/test/org/torproject/descriptor/impl/ConsensusBuilder.java @@ -106,8 +106,8 @@ public class ConsensusBuilder { cb.paramsLine = line; return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true); } - List<String> dirSources = new ArrayList<String>(); - List<String> statusEntries = new ArrayList<String>(); + List<String> dirSources = new ArrayList<>(); + List<String> statusEntries = new ArrayList<>(); private String directoryFooterLine = "directory-footer"; protected void setDirectoryFooterLine(String line) { this.directoryFooterLine = line; @@ -133,7 +133,7 @@ public class ConsensusBuilder { cb.bandwidthWeightsLine = line; return new RelayNetworkStatusConsensusImpl(cb.buildConsensus(), true); } - private List<String> directorySignatures = new ArrayList<String>(); + private List<String> directorySignatures = new ArrayList<>(); protected void addDirectorySignature(String directorySignatureString) { this.directorySignatures.add(directorySignatureString); } diff --git a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java index 55e0578..33540dc 100644 --- a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java +++ b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java @@ -1577,7 +1577,7 @@ public class ExtraInfoDescriptorImplTest { String unrecognizedLine = "unrecognized-line 1"; ExtraInfoDescriptor descriptor = DescriptorBuilder. createWithUnrecognizedLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines()); } diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java index 0707d55..1875774 100644 --- a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java +++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java @@ -1121,7 +1121,7 @@ public class RelayNetworkStatusConsensusImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusConsensus consensus = ConsensusBuilder. createWithUnrecognizedHeaderLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, consensus.getUnrecognizedLines()); } @@ -1140,7 +1140,7 @@ public class RelayNetworkStatusConsensusImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusConsensus consensus = ConsensusBuilder. createWithUnrecognizedDirSourceLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, consensus.getUnrecognizedLines()); } @@ -1159,7 +1159,7 @@ public class RelayNetworkStatusConsensusImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusConsensus consensus = ConsensusBuilder. createWithUnrecognizedStatusEntryLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, consensus.getUnrecognizedLines()); } @@ -1178,7 +1178,7 @@ public class RelayNetworkStatusConsensusImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusConsensus consensus = ConsensusBuilder. createWithUnrecognizedFooterLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, consensus.getUnrecognizedLines()); } @@ -1198,7 +1198,7 @@ public class RelayNetworkStatusConsensusImplTest { RelayNetworkStatusConsensus consensus = ConsensusBuilder. createWithUnrecognizedDirectorySignatureLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, consensus.getUnrecognizedLines()); } diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java index 46688d6..34e7721 100644 --- a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java +++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java @@ -1150,7 +1150,7 @@ public class RelayNetworkStatusVoteImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusVote vote = VoteBuilder. createWithUnrecognizedHeaderLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, vote.getUnrecognizedLines()); } @@ -1169,7 +1169,7 @@ public class RelayNetworkStatusVoteImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusVote vote = VoteBuilder. createWithUnrecognizedDirSourceLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, vote.getUnrecognizedLines()); } @@ -1187,7 +1187,7 @@ public class RelayNetworkStatusVoteImplTest { String unrecognizedLine = "unrecognized-line 1"; RelayNetworkStatusVote vote = VoteBuilder. createWithUnrecognizedFooterLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, vote.getUnrecognizedLines()); } diff --git a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java index 56f1419..41be8ea 100644 --- a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java +++ b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java @@ -1358,14 +1358,14 @@ public class ServerDescriptorImplTest { String unrecognizedLine = "unrecognized-line 1"; ServerDescriptor descriptor = DescriptorBuilder. createWithUnrecognizedLine(unrecognizedLine, false); - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add(unrecognizedLine); assertEquals(unrecognizedLines, descriptor.getUnrecognizedLines()); } @Test() public void testSomeOtherKey() throws DescriptorParseException { - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add("some-other-key"); unrecognizedLines.add("-----BEGIN RSA PUBLIC KEY-----"); unrecognizedLines.add("MIGJAoGBAKM+iiHhO6eHsvd6Xjws9z9EQB1V/Bpuy5ciGJ" @@ -1387,7 +1387,7 @@ public class ServerDescriptorImplTest { @Test() public void testUnrecognizedCryptoBlockNoKeyword() throws DescriptorParseException { - List<String> unrecognizedLines = new ArrayList<String>(); + List<String> unrecognizedLines = new ArrayList<>(); unrecognizedLines.add("-----BEGIN RSA PUBLIC KEY-----"); unrecognizedLines.add("MIGJAoGBAKM+iiHhO6eHsvd6Xjws9z9EQB1V/Bpuy5ciGJ" + "1U4V9SeiKooSo5BpPL");
participants (1)
-
karsten@torproject.org