tor-commits
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 215570 discussions
[metrics-lib/master] Use Java 7's diamond operator wherever possible.
by karsten@torproject.org 25 Dec '15
by karsten@torproject.org 25 Dec '15
25 Dec '15
commit ce18717907b502dfbc87f4b8567652ffe10fefe5
Author: Karsten Loesing <karsten.loesing(a)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");
1
0
[metrics-lib/master] Use Java 7's switch-on-String wherever possible.
by karsten@torproject.org 25 Dec '15
by karsten@torproject.org 25 Dec '15
25 Dec '15
commit 2b4d7732f65a8d030f7b747ed9931e5541956332
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Dec 22 12:55:44 2015 +0100
Use Java 7's switch-on-String wherever possible.
Rather than writing chained if-else statements with String comparison
for equals(), we can now switch on a String instance.
Suggested by iwakeh, implements #17824.
---
.../descriptor/DescriptorSourceFactory.java | 13 +-
.../descriptor/impl/BridgeNetworkStatusImpl.java | 51 +++--
.../impl/DirectoryKeyCertificateImpl.java | 95 ++++----
.../descriptor/impl/ExtraInfoDescriptorImpl.java | 228 ++++++++++++--------
.../descriptor/impl/MicrodescriptorImpl.java | 74 ++++---
.../descriptor/impl/NetworkStatusEntryImpl.java | 38 ++--
.../descriptor/impl/RelayDirectoryImpl.java | 75 ++++---
.../impl/RelayNetworkStatusConsensusImpl.java | 73 ++++---
.../descriptor/impl/RelayNetworkStatusImpl.java | 80 ++++---
.../impl/RelayNetworkStatusVoteImpl.java | 127 +++++++----
.../descriptor/impl/ServerDescriptorImpl.java | 199 ++++++++++-------
.../descriptor/impl/TorperfResultImpl.java | 87 +++++---
12 files changed, 700 insertions(+), 440 deletions(-)
diff --git a/src/org/torproject/descriptor/DescriptorSourceFactory.java b/src/org/torproject/descriptor/DescriptorSourceFactory.java
index 49fcdc6..8bab13e 100644
--- a/src/org/torproject/descriptor/DescriptorSourceFactory.java
+++ b/src/org/torproject/descriptor/DescriptorSourceFactory.java
@@ -53,14 +53,19 @@ public final class DescriptorSourceFactory {
Object object;
String clazzName = null;
try {
- if (PARSER_PROPERTY.equals(type)) {
+ switch (type) {
+ case PARSER_PROPERTY:
clazzName = System.getProperty(type, PARSER_DEFAULT);
- } else if (LOADER_PROPERTY.equals(type)) {
+ break;
+ case LOADER_PROPERTY:
clazzName = System.getProperty(type, LOADER_DEFAULT);
- } else if (READER_PROPERTY.equals(type)) {
+ break;
+ case READER_PROPERTY:
clazzName = System.getProperty(type, READER_DEFAULT);
- } else if (COLLECTOR_PROPERTY.equals(type)) {
+ break;
+ case COLLECTOR_PROPERTY:
clazzName = System.getProperty(type, COLLECTOR_DEFAULT);
+ break;
}
object = ClassLoader.getSystemClassLoader().loadClass(clazzName).
newInstance();
diff --git a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
index d5e6d8f..fcc9b64 100644
--- a/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/BridgeNetworkStatusImpl.java
@@ -73,18 +73,23 @@ public class BridgeNetworkStatusImpl extends NetworkStatusImpl
String line = s.next();
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("published")) {
+ switch (keyword) {
+ case "published":
this.parsePublishedLine(line, parts);
- } else if (keyword.equals("flag-thresholds")) {
+ break;
+ case "flag-thresholds":
this.parseFlagThresholdsLine(line, parts);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '" + line
- + "' in bridge network status.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '" + line
+ + "' in bridge network status.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
@@ -105,27 +110,37 @@ public class BridgeNetworkStatusImpl extends NetworkStatusImpl
ParseHelper.parseKeyValueStringPairs(line, parts, 1, "=");
try {
for (Map.Entry<String, String> e : flagThresholds.entrySet()) {
- if (e.getKey().equals("stable-uptime")) {
+ switch (e.getKey()) {
+ case "stable-uptime":
this.stableUptime = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("stable-mtbf")) {
+ break;
+ case "stable-mtbf":
this.stableMtbf = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("fast-speed")) {
+ break;
+ case "fast-speed":
this.fastBandwidth = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-wfu")) {
+ break;
+ case "guard-wfu":
this.guardWfu = Double.parseDouble(e.getValue().
replaceAll("%", ""));
- } else if (e.getKey().equals("guard-tk")) {
+ break;
+ case "guard-tk":
this.guardTk = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-bw-inc-exits")) {
+ break;
+ case "guard-bw-inc-exits":
this.guardBandwidthIncludingExits =
Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-bw-exc-exits")) {
+ break;
+ case "guard-bw-exc-exits":
this.guardBandwidthExcludingExits =
Long.parseLong(e.getValue());
- } else if (e.getKey().equals("enough-mtbf")) {
+ break;
+ case "enough-mtbf":
this.enoughMtbfInfo = Integer.parseInt(e.getValue());
- } else if (e.getKey().equals("ignoring-advertised-bws")) {
+ break;
+ case "ignoring-advertised-bws":
this.ignoringAdvertisedBws = Integer.parseInt(e.getValue());
+ break;
}
}
} catch (NumberFormatException ex) {
diff --git a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
index 152ffeb..fcbf3f7 100644
--- a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
@@ -60,65 +60,82 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl
private void parseDescriptorBytes() throws DescriptorParseException {
Scanner s = new Scanner(new String(this.rawDescriptorBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
StringBuilder crypto = null;
while (s.hasNext()) {
String line = s.next();
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("dir-key-certificate-version")) {
+ switch (keyword) {
+ case "dir-key-certificate-version":
this.parseDirKeyCertificateVersionLine(line, parts);
- } else if (keyword.equals("dir-address")) {
+ break;
+ case "dir-address":
this.parseDirAddressLine(line, parts);
- } else if (keyword.equals("fingerprint")) {
+ break;
+ case "fingerprint":
this.parseFingerprintLine(line, parts);
- } else if (keyword.equals("dir-identity-key")) {
+ break;
+ case "dir-identity-key":
this.parseDirIdentityKeyLine(line, parts);
nextCrypto = "dir-identity-key";
- } else if (keyword.equals("dir-key-published")) {
+ break;
+ case "dir-key-published":
this.parseDirKeyPublishedLine(line, parts);
- } else if (keyword.equals("dir-key-expires")) {
+ break;
+ case "dir-key-expires":
this.parseDirKeyExpiresLine(line, parts);
- } else if (keyword.equals("dir-signing-key")) {
+ break;
+ case "dir-signing-key":
this.parseDirSigningKeyLine(line, parts);
nextCrypto = "dir-signing-key";
- } else if (keyword.equals("dir-key-crosscert")) {
+ break;
+ case "dir-key-crosscert":
this.parseDirKeyCrosscertLine(line, parts);
nextCrypto = "dir-key-crosscert";
- } else if (keyword.equals("dir-key-certification")) {
+ break;
+ case "dir-key-certification":
this.parseDirKeyCertificationLine(line, parts);
nextCrypto = "dir-key-certification";
- } else if (line.startsWith("-----BEGIN")) {
- crypto = new StringBuilder();
- crypto.append(line + "\n");
- } else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
- String cryptoString = crypto.toString();
- crypto = null;
- if (nextCrypto.equals("dir-identity-key")) {
- this.dirIdentityKey = cryptoString;
- } else if (nextCrypto.equals("dir-signing-key")) {
- this.dirSigningKey = cryptoString;
- } else if (nextCrypto.equals("dir-key-crosscert")) {
- this.dirKeyCrosscert = cryptoString;
- } else if (nextCrypto.equals("dir-key-certification")) {
- this.dirKeyCertification = cryptoString;
- } else {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block in directory key certificate.");
- }
- nextCrypto = null;
- } else if (crypto != null) {
- crypto.append(line + "\n");
- } else {
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in directory key certificate.");
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ crypto = new StringBuilder();
+ crypto.append(line + "\n");
+ } else if (line.startsWith("-----END")) {
+ crypto.append(line + "\n");
+ String cryptoString = crypto.toString();
+ crypto = null;
+ switch (nextCrypto) {
+ case "dir-identity-key":
+ this.dirIdentityKey = cryptoString;
+ break;
+ case "dir-signing-key":
+ this.dirSigningKey = cryptoString;
+ break;
+ case "dir-key-crosscert":
+ this.dirKeyCrosscert = cryptoString;
+ break;
+ case "dir-key-certification":
+ this.dirKeyCertification = cryptoString;
+ break;
+ default:
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block in directory key certificate.");
+ }
+ nextCrypto = "";
+ } else if (crypto != null) {
+ crypto.append(line + "\n");
} else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in directory key certificate.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
index ff8df51..36ff269 100644
--- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
@@ -79,7 +79,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
private void parseDescriptorBytes() throws DescriptorParseException {
Scanner s = new Scanner(new String(this.rawDescriptorBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
List<String> cryptoLines = null;
while (s.hasNext()) {
String line = s.next();
@@ -87,145 +87,203 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
line.substring("opt ".length()) : line;
String[] partsNoOpt = lineNoOpt.split("[ \t]+");
String keyword = partsNoOpt[0];
- if (keyword.equals("extra-info")) {
+ switch (keyword) {
+ case "extra-info":
this.parseExtraInfoLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("published")) {
+ break;
+ case "published":
this.parsePublishedLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("read-history")) {
+ break;
+ case "read-history":
this.parseReadHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("write-history")) {
+ break;
+ case "write-history":
this.parseWriteHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("geoip-db-digest")) {
+ break;
+ case "geoip-db-digest":
this.parseGeoipDbDigestLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("geoip6-db-digest")) {
+ break;
+ case "geoip6-db-digest":
this.parseGeoip6DbDigestLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("geoip-start-time")) {
+ break;
+ case "geoip-start-time":
this.parseGeoipStartTimeLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("geoip-client-origins")) {
+ break;
+ case "geoip-client-origins":
this.parseGeoipClientOriginsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-stats-end")) {
+ break;
+ case "dirreq-stats-end":
this.parseDirreqStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-ips")) {
+ break;
+ case "dirreq-v2-ips":
this.parseDirreqV2IpsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-ips")) {
+ break;
+ case "dirreq-v3-ips":
this.parseDirreqV3IpsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-reqs")) {
+ break;
+ case "dirreq-v2-reqs":
this.parseDirreqV2ReqsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-reqs")) {
+ break;
+ case "dirreq-v3-reqs":
this.parseDirreqV3ReqsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-share")) {
+ break;
+ case "dirreq-v2-share":
this.parseDirreqV2ShareLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-share")) {
+ break;
+ case "dirreq-v3-share":
this.parseDirreqV3ShareLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-resp")) {
+ break;
+ case "dirreq-v2-resp":
this.parseDirreqV2RespLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-resp")) {
+ break;
+ case "dirreq-v3-resp":
this.parseDirreqV3RespLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-direct-dl")) {
+ break;
+ case "dirreq-v2-direct-dl":
this.parseDirreqV2DirectDlLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-direct-dl")) {
+ break;
+ case "dirreq-v3-direct-dl":
this.parseDirreqV3DirectDlLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v2-tunneled-dl")) {
+ break;
+ case "dirreq-v2-tunneled-dl":
this.parseDirreqV2TunneledDlLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-v3-tunneled-dl")) {
+ break;
+ case "dirreq-v3-tunneled-dl":
this.parseDirreqV3TunneledDlLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-read-history")) {
+ break;
+ case "dirreq-read-history":
this.parseDirreqReadHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dirreq-write-history")) {
+ break;
+ case "dirreq-write-history":
this.parseDirreqWriteHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("entry-stats-end")) {
+ break;
+ case "entry-stats-end":
this.parseEntryStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("entry-ips")) {
+ break;
+ case "entry-ips":
this.parseEntryIpsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("cell-stats-end")) {
+ break;
+ case "cell-stats-end":
this.parseCellStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("cell-processed-cells")) {
+ break;
+ case "cell-processed-cells":
this.parseCellProcessedCellsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("cell-queued-cells")) {
+ break;
+ case "cell-queued-cells":
this.parseCellQueuedCellsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("cell-time-in-queue")) {
+ break;
+ case "cell-time-in-queue":
this.parseCellTimeInQueueLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("cell-circuits-per-decile")) {
+ break;
+ case "cell-circuits-per-decile":
this.parseCellCircuitsPerDecileLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("conn-bi-direct")) {
+ break;
+ case "conn-bi-direct":
this.parseConnBiDirectLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("exit-stats-end")) {
+ break;
+ case "exit-stats-end":
this.parseExitStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("exit-kibibytes-written")) {
+ break;
+ case "exit-kibibytes-written":
this.parseExitKibibytesWrittenLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("exit-kibibytes-read")) {
+ break;
+ case "exit-kibibytes-read":
this.parseExitKibibytesReadLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("exit-streams-opened")) {
+ break;
+ case "exit-streams-opened":
this.parseExitStreamsOpenedLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("bridge-stats-end")) {
+ break;
+ case "bridge-stats-end":
this.parseBridgeStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("bridge-ips")) {
+ break;
+ case "bridge-ips":
this.parseBridgeStatsIpsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("bridge-ip-versions")) {
+ break;
+ case "bridge-ip-versions":
this.parseBridgeIpVersionsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("bridge-ip-transports")) {
+ break;
+ case "bridge-ip-transports":
this.parseBridgeIpTransportsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("transport")) {
+ break;
+ case "transport":
this.parseTransportLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("hidserv-stats-end")) {
+ break;
+ case "hidserv-stats-end":
this.parseHidservStatsEndLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("hidserv-rend-relayed-cells")) {
+ break;
+ case "hidserv-rend-relayed-cells":
this.parseHidservRendRelayedCellsLine(line, lineNoOpt,
partsNoOpt);
- } else if (keyword.equals("hidserv-dir-onions-seen")) {
+ break;
+ case "hidserv-dir-onions-seen":
this.parseHidservDirOnionsSeenLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("identity-ed25519")) {
+ break;
+ case "identity-ed25519":
this.parseIdentityEd25519Line(line, lineNoOpt, partsNoOpt);
nextCrypto = "identity-ed25519";
- } else if (keyword.equals("master-key-ed25519")) {
+ break;
+ case "master-key-ed25519":
this.parseMasterKeyEd25519Line(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-sig-ed25519")) {
+ break;
+ case "router-sig-ed25519":
this.parseRouterSigEd25519Line(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-signature")) {
+ break;
+ case "router-signature":
this.parseRouterSignatureLine(line, lineNoOpt, partsNoOpt);
nextCrypto = "router-signature";
- } else if (keyword.equals("router-digest")) {
+ break;
+ case "router-digest":
this.parseRouterDigestLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-digest-sha256")) {
+ break;
+ case "router-digest-sha256":
this.parseRouterDigestSha256Line(line, lineNoOpt, partsNoOpt);
- } else if (line.startsWith("-----BEGIN")) {
- cryptoLines = new ArrayList<>();
- cryptoLines.add(line);
- } else if (line.startsWith("-----END")) {
- cryptoLines.add(line);
- StringBuilder sb = new StringBuilder();
- for (String cryptoLine : cryptoLines) {
- sb.append("\n" + cryptoLine);
- }
- String cryptoString = sb.toString().substring(1);
- if ("router-signature".equals(nextCrypto)) {
- this.routerSignature = cryptoString;
- } else if ("identity-ed25519".equals(nextCrypto)) {
- this.identityEd25519 = cryptoString;
- this.parseIdentityEd25519CryptoBlock(cryptoString);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block '" + cryptoString + "' in extra-info descriptor.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ cryptoLines = new ArrayList<>();
+ cryptoLines.add(line);
+ } else if (line.startsWith("-----END")) {
+ cryptoLines.add(line);
+ StringBuilder sb = new StringBuilder();
+ for (String cryptoLine : cryptoLines) {
+ sb.append("\n" + cryptoLine);
}
- this.unrecognizedLines.addAll(cryptoLines);
- }
- cryptoLines = null;
- nextCrypto = null;
- } else if (cryptoLines != null) {
- cryptoLines.add(line);
- } else {
- ParseHelper.parseKeyword(line, partsNoOpt[0]);
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in extra-info descriptor.");
+ String cryptoString = sb.toString().substring(1);
+ switch (nextCrypto) {
+ case "router-signature":
+ this.routerSignature = cryptoString;
+ break;
+ case "identity-ed25519":
+ this.identityEd25519 = cryptoString;
+ this.parseIdentityEd25519CryptoBlock(cryptoString);
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block '" + cryptoString + "' in extra-info "
+ + "descriptor.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.addAll(cryptoLines);
+ }
+ }
+ cryptoLines = null;
+ nextCrypto = "";
+ } else if (cryptoLines != null) {
+ cryptoLines.add(line);
} else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ ParseHelper.parseKeyword(line, partsNoOpt[0]);
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in extra-info descriptor.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
index 3e7f466..a70493d 100644
--- a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
@@ -57,7 +57,7 @@ public class MicrodescriptorImpl extends DescriptorImpl
private void parseDescriptorBytes() throws DescriptorParseException {
Scanner s = new Scanner(new String(this.rawDescriptorBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
StringBuilder crypto = null;
while (s.hasNext()) {
String line = s.next();
@@ -66,47 +66,57 @@ public class MicrodescriptorImpl extends DescriptorImpl
}
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("onion-key")) {
+ switch (keyword) {
+ case "onion-key":
this.parseOnionKeyLine(line, parts);
nextCrypto = "onion-key";
- } else if (keyword.equals("ntor-onion-key")) {
+ break;
+ case "ntor-onion-key":
this.parseNtorOnionKeyLine(line, parts);
- } else if (keyword.equals("a")) {
+ break;
+ case "a":
this.parseALine(line, parts);
- } else if (keyword.equals("family")) {
+ break;
+ case "family":
this.parseFamilyLine(line, parts);
- } else if (keyword.equals("p")) {
+ break;
+ case "p":
this.parsePLine(line, parts);
- } else if (keyword.equals("p6")) {
+ break;
+ case "p6":
this.parseP6Line(line, parts);
- } else if (keyword.equals("id")) {
+ break;
+ case "id":
this.parseIdLine(line, parts);
- } else if (line.startsWith("-----BEGIN")) {
- crypto = new StringBuilder();
- crypto.append(line + "\n");
- } else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
- String cryptoString = crypto.toString();
- crypto = null;
- if (nextCrypto.equals("onion-key")) {
- this.onionKey = cryptoString;
- } else {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block in microdescriptor.");
- }
- nextCrypto = null;
- } else if (crypto != null) {
- crypto.append(line + "\n");
- } else {
- ParseHelper.parseKeyword(line, parts[0]);
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in microdescriptor.");
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ crypto = new StringBuilder();
+ crypto.append(line + "\n");
+ } else if (line.startsWith("-----END")) {
+ crypto.append(line + "\n");
+ String cryptoString = crypto.toString();
+ crypto = null;
+ if (nextCrypto.equals("onion-key")) {
+ this.onionKey = cryptoString;
+ } else {
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block in microdescriptor.");
+ }
+ nextCrypto = "";
+ } else if (crypto != null) {
+ crypto.append(line + "\n");
} else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ ParseHelper.parseKeyword(line, parts[0]);
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in microdescriptor.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
index 4f2b69b..c5f0704 100644
--- a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
@@ -79,28 +79,38 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
String[] parts = !line.startsWith("opt ") ? line.split("[ \t]+") :
line.substring("opt ".length()).split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("a")) {
+ switch (keyword) {
+ case "a":
this.parseALine(line, parts);
- } else if (keyword.equals("s")) {
+ break;
+ case "s":
this.parseSLine(line, parts);
- } else if (keyword.equals("v")) {
+ break;
+ case "v":
this.parseVLine(line, parts);
- } else if (keyword.equals("w")) {
+ break;
+ case "w":
this.parseWLine(line, parts);
- } else if (keyword.equals("p")) {
+ break;
+ case "p":
this.parsePLine(line, parts);
- } else if (keyword.equals("m")) {
+ break;
+ case "m":
this.parseMLine(line, parts);
- } else if (keyword.equals("id")) {
+ break;
+ case "id":
this.parseIdLine(line, parts);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '" + line
- + "' in status entry.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '" + line
+ + "' in status entry.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
index 0b82328..4d583aa 100644
--- a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
@@ -189,7 +189,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
private void parseHeader(byte[] headerBytes)
throws DescriptorParseException {
Scanner s = new Scanner(new String(headerBytes)).useDelimiter("\n");
- String publishedLine = null, nextCrypto = null,
+ String publishedLine = null, nextCrypto = "",
runningRoutersLine = null, routerStatusLine = null;
StringBuilder crypto = null;
while (s.hasNext()) {
@@ -201,9 +201,11 @@ public class RelayDirectoryImpl extends DescriptorImpl
line.substring("opt ".length()) : line;
String[] partsNoOpt = lineNoOpt.split("[ \t]+");
String keyword = partsNoOpt[0];
- if (keyword.equals("signed-directory")) {
+ switch (keyword) {
+ case "signed-directory":
this.parseSignedDirectoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("published")) {
+ break;
+ case "published":
if (publishedLine != null) {
throw new DescriptorParseException("Keyword 'published' is "
+ "contained more than once, but must be contained exactly "
@@ -211,41 +213,48 @@ public class RelayDirectoryImpl extends DescriptorImpl
} else {
publishedLine = line;
}
- } else if (keyword.equals("dir-signing-key")) {
+ break;
+ case "dir-signing-key":
this.parseDirSigningKeyLine(line, lineNoOpt, partsNoOpt);
nextCrypto = "dir-signing-key";
- } else if (keyword.equals("recommended-software")) {
+ break;
+ case "recommended-software":
this.parseRecommendedSoftwareLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("running-routers")) {
+ break;
+ case "running-routers":
runningRoutersLine = line;
- } else if (keyword.equals("router-status")) {
+ break;
+ case "router-status":
routerStatusLine = line;
- } else if (line.startsWith("-----BEGIN")) {
- crypto = new StringBuilder();
- crypto.append(line + "\n");
- } else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
- String cryptoString = crypto.toString();
- crypto = null;
- if (nextCrypto.equals("dir-signing-key") &&
- this.dirSigningKey == null) {
- this.dirSigningKey = cryptoString;
- } else {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block in v1 directory.");
- }
- nextCrypto = null;
- } else if (crypto != null) {
- crypto.append(line + "\n");
- } else {
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in v1 directory.");
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ crypto = new StringBuilder();
+ crypto.append(line + "\n");
+ } else if (line.startsWith("-----END")) {
+ crypto.append(line + "\n");
+ String cryptoString = crypto.toString();
+ crypto = null;
+ if (nextCrypto.equals("dir-signing-key") &&
+ this.dirSigningKey == null) {
+ this.dirSigningKey = cryptoString;
+ } else {
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block in v1 directory.");
+ }
+ nextCrypto = "";
+ } else if (crypto != null) {
+ crypto.append(line + "\n");
} else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in v1 directory.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
@@ -296,7 +305,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
throws DescriptorParseException {
Scanner s = new Scanner(new String(directorySignatureBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
StringBuilder crypto = null;
while (s.hasNext()) {
String line = s.next();
@@ -320,7 +329,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
throw new DescriptorParseException("Unrecognized crypto "
+ "block in v2 network status.");
}
- nextCrypto = null;
+ nextCrypto = "";
} else if (crypto != null) {
crypto.append(line + "\n");
} else if (this.failUnrecognizedDescriptorLines) {
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
index d92718c..13b9142 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
@@ -95,36 +95,50 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
String line = s.next();
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("network-status-version")) {
+ switch (keyword) {
+ case "network-status-version":
this.parseNetworkStatusVersionLine(line, parts);
- } else if (keyword.equals("vote-status")) {
+ break;
+ case "vote-status":
this.parseVoteStatusLine(line, parts);
- } else if (keyword.equals("consensus-method")) {
+ break;
+ case "consensus-method":
this.parseConsensusMethodLine(line, parts);
- } else if (keyword.equals("valid-after")) {
+ break;
+ case "valid-after":
this.parseValidAfterLine(line, parts);
- } else if (keyword.equals("fresh-until")) {
+ break;
+ case "fresh-until":
this.parseFreshUntilLine(line, parts);
- } else if (keyword.equals("valid-until")) {
+ break;
+ case "valid-until":
this.parseValidUntilLine(line, parts);
- } else if (keyword.equals("voting-delay")) {
+ break;
+ case "voting-delay":
this.parseVotingDelayLine(line, parts);
- } else if (keyword.equals("client-versions")) {
+ break;
+ case "client-versions":
this.parseClientVersionsLine(line, parts);
- } else if (keyword.equals("server-versions")) {
+ break;
+ case "server-versions":
this.parseServerVersionsLine(line, parts);
- } else if (keyword.equals("known-flags")) {
+ break;
+ case "known-flags":
this.parseKnownFlagsLine(line, parts);
- } else if (keyword.equals("params")) {
+ break;
+ case "params":
this.parseParamsLine(line, parts);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '" + line
- + "' in consensus.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '" + line
+ + "' in consensus.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
@@ -153,17 +167,22 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
String line = s.next();
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("directory-footer")) {
- } else if (keyword.equals("bandwidth-weights")) {
+ switch (keyword) {
+ case "directory-footer":
+ break;
+ case "bandwidth-weights":
this.parseBandwidthWeightsLine(line, parts);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '" + line
- + "' in consensus.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '" + line
+ + "' in consensus.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index c2735e7..a10ed7a 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -88,7 +88,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
protected void parseHeader(byte[] headerBytes)
throws DescriptorParseException {
Scanner s = new Scanner(new String(headerBytes)).useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
StringBuilder crypto = null;
while (s.hasNext()) {
String line = s.next();
@@ -97,49 +97,61 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
}
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("network-status-version")) {
+ switch (keyword) {
+ case "network-status-version":
this.parseNetworkStatusVersionLine(line, parts);
- } else if (keyword.equals("dir-source")) {
+ break;
+ case "dir-source":
this.parseDirSourceLine(line, parts);
- } else if (keyword.equals("fingerprint")) {
+ break;
+ case "fingerprint":
this.parseFingerprintLine(line, parts);
- } else if (keyword.equals("contact")) {
+ break;
+ case "contact":
this.parseContactLine(line, parts);
- } else if (keyword.equals("dir-signing-key")) {
+ break;
+ case "dir-signing-key":
this.parseDirSigningKeyLine(line, parts);
nextCrypto = "dir-signing-key";
- } else if (keyword.equals("client-versions")) {
+ break;
+ case "client-versions":
this.parseClientVersionsLine(line, parts);
- } else if (keyword.equals("server-versions")) {
+ break;
+ case "server-versions":
this.parseServerVersionsLine(line, parts);
- } else if (keyword.equals("published")) {
+ break;
+ case "published":
this.parsePublishedLine(line, parts);
- } else if (keyword.equals("dir-options")) {
+ break;
+ case "dir-options":
this.parseDirOptionsLine(line, parts);
- } else if (line.startsWith("-----BEGIN")) {
- crypto = new StringBuilder();
- crypto.append(line + "\n");
- } else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
- String cryptoString = crypto.toString();
- crypto = null;
- if (nextCrypto.equals("dir-signing-key")) {
- this.dirSigningKey = cryptoString;
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ crypto = new StringBuilder();
+ crypto.append(line + "\n");
+ } else if (line.startsWith("-----END")) {
+ crypto.append(line + "\n");
+ String cryptoString = crypto.toString();
+ crypto = null;
+ if (nextCrypto.equals("dir-signing-key")) {
+ this.dirSigningKey = cryptoString;
+ } else {
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block in v2 network status.");
+ }
+ nextCrypto = "";
+ } else if (crypto != null) {
+ crypto.append(line + "\n");
+ } else if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '" + line
+ + "' in v2 network status.");
} else {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block in v2 network status.");
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- nextCrypto = null;
- } else if (crypto != null) {
- crypto.append(line + "\n");
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '" + line
- + "' in v2 network status.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
- }
- this.unrecognizedLines.add(line);
}
}
}
@@ -154,7 +166,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
throws DescriptorParseException {
Scanner s = new Scanner(new String(directorySignatureBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
StringBuilder crypto = null;
while (s.hasNext()) {
String line = s.next();
@@ -176,7 +188,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
throw new DescriptorParseException("Unrecognized crypto "
+ "block in v2 network status.");
}
- nextCrypto = null;
+ nextCrypto = "";
} else if (crypto != null) {
crypto.append(line + "\n");
} else if (this.failUnrecognizedDescriptorLines) {
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index b8f0412..d74ef65 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -79,65 +79,90 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
String line = s.next();
String[] parts = line.split("[ \t]+");
String keyword = parts[0];
- if (keyword.equals("network-status-version")) {
+ switch (keyword) {
+ case "network-status-version":
this.parseNetworkStatusVersionLine(line, parts);
- } else if (keyword.equals("vote-status")) {
+ break;
+ case "vote-status":
this.parseVoteStatusLine(line, parts);
- } else if (keyword.equals("consensus-methods")) {
+ break;
+ case "consensus-methods":
this.parseConsensusMethodsLine(line, parts);
- } else if (keyword.equals("published")) {
+ break;
+ case "published":
this.parsePublishedLine(line, parts);
- } else if (keyword.equals("valid-after")) {
+ break;
+ case "valid-after":
this.parseValidAfterLine(line, parts);
- } else if (keyword.equals("fresh-until")) {
+ break;
+ case "fresh-until":
this.parseFreshUntilLine(line, parts);
- } else if (keyword.equals("valid-until")) {
+ break;
+ case "valid-until":
this.parseValidUntilLine(line, parts);
- } else if (keyword.equals("voting-delay")) {
+ break;
+ case "voting-delay":
this.parseVotingDelayLine(line, parts);
- } else if (keyword.equals("client-versions")) {
+ break;
+ case "client-versions":
this.parseClientVersionsLine(line, parts);
- } else if (keyword.equals("server-versions")) {
+ break;
+ case "server-versions":
this.parseServerVersionsLine(line, parts);
- } else if (keyword.equals("known-flags")) {
+ break;
+ case "known-flags":
this.parseKnownFlagsLine(line, parts);
- } else if (keyword.equals("flag-thresholds")) {
+ break;
+ case "flag-thresholds":
this.parseFlagThresholdsLine(line, parts);
- } else if (keyword.equals("params")) {
+ break;
+ case "params":
this.parseParamsLine(line, parts);
- } else if (keyword.equals("dir-source")) {
+ break;
+ case "dir-source":
this.parseDirSourceLine(line, parts);
- } else if (keyword.equals("contact")) {
+ break;
+ case "contact":
this.parseContactLine(line, parts);
- } else if (keyword.equals("dir-key-certificate-version")) {
+ break;
+ case "dir-key-certificate-version":
this.parseDirKeyCertificateVersionLine(line, parts);
- } else if (keyword.equals("dir-address")) {
+ break;
+ case "dir-address":
this.parseDirAddressLine(line, parts);
- } else if (keyword.equals("fingerprint")) {
+ break;
+ case "fingerprint":
this.parseFingerprintLine(line, parts);
- } else if (keyword.equals("legacy-dir-key")) {
+ break;
+ case "legacy-dir-key":
this.parseLegacyDirKeyLine(line, parts);
- } else if (keyword.equals("dir-key-published")) {
+ break;
+ case "dir-key-published":
this.parseDirKeyPublished(line, parts);
- } else if (keyword.equals("dir-key-expires")) {
+ break;
+ case "dir-key-expires":
this.parseDirKeyExpiresLine(line, parts);
- } else if (keyword.equals("dir-identity-key") ||
- keyword.equals("dir-signing-key") ||
- keyword.equals("dir-key-crosscert") ||
- keyword.equals("dir-key-certification")) {
- } else if (line.startsWith("-----BEGIN")) {
- skipCrypto = true;
- } else if (line.startsWith("-----END")) {
- skipCrypto = false;
- } else if (!skipCrypto) {
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in vote.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ case "dir-identity-key":
+ case "dir-signing-key":
+ case "dir-key-crosscert":
+ case "dir-key-certification":
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ skipCrypto = true;
+ } else if (line.startsWith("-----END")) {
+ skipCrypto = false;
+ } else if (!skipCrypto) {
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in vote.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
@@ -257,27 +282,37 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
ParseHelper.parseKeyValueStringPairs(line, parts, 1, "=");
try {
for (Map.Entry<String, String> e : flagThresholds.entrySet()) {
- if (e.getKey().equals("stable-uptime")) {
+ switch (e.getKey()) {
+ case "stable-uptime":
this.stableUptime = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("stable-mtbf")) {
+ break;
+ case "stable-mtbf":
this.stableMtbf = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("fast-speed")) {
+ break;
+ case "fast-speed":
this.fastBandwidth = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-wfu")) {
+ break;
+ case "guard-wfu":
this.guardWfu = Double.parseDouble(e.getValue().
replaceAll("%", ""));
- } else if (e.getKey().equals("guard-tk")) {
+ break;
+ case "guard-tk":
this.guardTk = Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-bw-inc-exits")) {
+ break;
+ case "guard-bw-inc-exits":
this.guardBandwidthIncludingExits =
Long.parseLong(e.getValue());
- } else if (e.getKey().equals("guard-bw-exc-exits")) {
+ break;
+ case "guard-bw-exc-exits":
this.guardBandwidthExcludingExits =
Long.parseLong(e.getValue());
- } else if (e.getKey().equals("enough-mtbf")) {
+ break;
+ case "enough-mtbf":
this.enoughMtbfInfo = Integer.parseInt(e.getValue());
- } else if (e.getKey().equals("ignoring-advertised-bws")) {
+ break;
+ case "ignoring-advertised-bws":
this.ignoringAdvertisedBws = Integer.parseInt(e.getValue());
+ break;
}
}
} catch (NumberFormatException ex) {
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index ddca784..4ed311e 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -54,7 +54,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
private void parseDescriptorBytes() throws DescriptorParseException {
Scanner s = new Scanner(new String(this.rawDescriptorBytes)).
useDelimiter("\n");
- String nextCrypto = null;
+ String nextCrypto = "";
List<String> cryptoLines = null;
while (s.hasNext()) {
String line = s.next();
@@ -65,124 +65,169 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
line.substring("opt ".length()) : line;
String[] partsNoOpt = lineNoOpt.split("[ \t]+");
String keyword = partsNoOpt[0];
- if (keyword.equals("router")) {
+ switch (keyword) {
+ case "router":
this.parseRouterLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("or-address")) {
+ break;
+ case "or-address":
this.parseOrAddressLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("bandwidth")) {
+ break;
+ case "bandwidth":
this.parseBandwidthLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("platform")) {
+ break;
+ case "platform":
this.parsePlatformLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("published")) {
+ break;
+ case "published":
this.parsePublishedLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("fingerprint")) {
+ break;
+ case "fingerprint":
this.parseFingerprintLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("hibernating")) {
+ break;
+ case "hibernating":
this.parseHibernatingLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("uptime")) {
+ break;
+ case "uptime":
this.parseUptimeLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("onion-key")) {
+ break;
+ case "onion-key":
this.parseOnionKeyLine(line, lineNoOpt, partsNoOpt);
nextCrypto = "onion-key";
- } else if (keyword.equals("signing-key")) {
+ break;
+ case "signing-key":
this.parseSigningKeyLine(line, lineNoOpt, partsNoOpt);
nextCrypto = "signing-key";
- } else if (keyword.equals("accept")) {
+ break;
+ case "accept":
this.parseAcceptLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("reject")) {
+ break;
+ case "reject":
this.parseRejectLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-signature")) {
+ break;
+ case "router-signature":
this.parseRouterSignatureLine(line, lineNoOpt, partsNoOpt);
nextCrypto = "router-signature";
- } else if (keyword.equals("contact")) {
+ break;
+ case "contact":
this.parseContactLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("family")) {
+ break;
+ case "family":
this.parseFamilyLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("read-history")) {
+ break;
+ case "read-history":
this.parseReadHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("write-history")) {
+ break;
+ case "write-history":
this.parseWriteHistoryLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("eventdns")) {
+ break;
+ case "eventdns":
this.parseEventdnsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("caches-extra-info")) {
+ break;
+ case "caches-extra-info":
this.parseCachesExtraInfoLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("extra-info-digest")) {
+ break;
+ case "extra-info-digest":
this.parseExtraInfoDigestLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("hidden-service-dir")) {
+ break;
+ case "hidden-service-dir":
this.parseHiddenServiceDirLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("protocols")) {
+ break;
+ case "protocols":
this.parseProtocolsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("allow-single-hop-exits")) {
+ break;
+ case "allow-single-hop-exits":
this.parseAllowSingleHopExitsLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("dircacheport")) {
+ break;
+ case "dircacheport":
this.parseDircacheportLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-digest")) {
+ break;
+ case "router-digest":
this.parseRouterDigestLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-digest-sha256")) {
+ break;
+ case "router-digest-sha256":
this.parseRouterDigestSha256Line(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("ipv6-policy")) {
+ break;
+ case "ipv6-policy":
this.parseIpv6PolicyLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("ntor-onion-key")) {
+ break;
+ case "ntor-onion-key":
this.parseNtorOnionKeyLine(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("identity-ed25519")) {
+ break;
+ case "identity-ed25519":
this.parseIdentityEd25519Line(line, lineNoOpt, partsNoOpt);
nextCrypto = "identity-ed25519";
- } else if (keyword.equals("master-key-ed25519")) {
+ break;
+ case "master-key-ed25519":
this.parseMasterKeyEd25519Line(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("router-sig-ed25519")) {
+ break;
+ case "router-sig-ed25519":
this.parseRouterSigEd25519Line(line, lineNoOpt, partsNoOpt);
- } else if (keyword.equals("onion-key-crosscert")) {
+ break;
+ case "onion-key-crosscert":
this.parseOnionKeyCrosscert(line, lineNoOpt, partsNoOpt);
nextCrypto = "onion-key-crosscert";
- } else if (keyword.equals("ntor-onion-key-crosscert")) {
+ break;
+ case "ntor-onion-key-crosscert":
this.parseNtorOnionKeyCrosscert(line, lineNoOpt, partsNoOpt);
nextCrypto = "ntor-onion-key-crosscert";
- } else if (line.startsWith("-----BEGIN")) {
- cryptoLines = new ArrayList<>();
- cryptoLines.add(line);
- } else if (line.startsWith("-----END")) {
- cryptoLines.add(line);
- StringBuilder sb = new StringBuilder();
- for (String cryptoLine : cryptoLines) {
- sb.append("\n" + cryptoLine);
- }
- String cryptoString = sb.toString().substring(1);
- if ("onion-key".equals(nextCrypto)) {
- this.onionKey = cryptoString;
- } else if ("signing-key".equals(nextCrypto)) {
- this.signingKey = cryptoString;
- } else if ("router-signature".equals(nextCrypto)) {
- this.routerSignature = cryptoString;
- } else if ("identity-ed25519".equals(nextCrypto)) {
- this.identityEd25519 = cryptoString;
- this.parseIdentityEd25519CryptoBlock(cryptoString);
- } else if ("onion-key-crosscert".equals(nextCrypto)) {
- this.onionKeyCrosscert = cryptoString;
- } else if ("ntor-onion-key-crosscert".equals(nextCrypto)) {
- this.ntorOnionKeyCrosscert = cryptoString;
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized crypto "
- + "block '" + cryptoString + "' in server descriptor.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (line.startsWith("-----BEGIN")) {
+ cryptoLines = new ArrayList<>();
+ cryptoLines.add(line);
+ } else if (line.startsWith("-----END")) {
+ cryptoLines.add(line);
+ StringBuilder sb = new StringBuilder();
+ for (String cryptoLine : cryptoLines) {
+ sb.append("\n" + cryptoLine);
}
- this.unrecognizedLines.addAll(cryptoLines);
- }
- cryptoLines = null;
- nextCrypto = null;
- } else if (cryptoLines != null) {
- cryptoLines.add(line);
- } else {
- ParseHelper.parseKeyword(line, partsNoOpt[0]);
- if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized line '"
- + line + "' in server descriptor.");
+ String cryptoString = sb.toString().substring(1);
+ switch (nextCrypto) {
+ case "onion-key":
+ this.onionKey = cryptoString;
+ break;
+ case "signing-key":
+ this.signingKey = cryptoString;
+ break;
+ case "router-signature":
+ this.routerSignature = cryptoString;
+ break;
+ case "identity-ed25519":
+ this.identityEd25519 = cryptoString;
+ this.parseIdentityEd25519CryptoBlock(cryptoString);
+ break;
+ case "onion-key-crosscert":
+ this.onionKeyCrosscert = cryptoString;
+ break;
+ case "ntor-onion-key-crosscert":
+ this.ntorOnionKeyCrosscert = cryptoString;
+ break;
+ default:
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized crypto "
+ + "block '" + cryptoString + "' in server descriptor.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.addAll(cryptoLines);
+ }
+ }
+ cryptoLines = null;
+ nextCrypto = "";
+ } else if (cryptoLines != null) {
+ cryptoLines.add(line);
} else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ ParseHelper.parseKeyword(line, partsNoOpt[0]);
+ if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized line '"
+ + line + "' in server descriptor.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
}
diff --git a/src/org/torproject/descriptor/impl/TorperfResultImpl.java b/src/org/torproject/descriptor/impl/TorperfResultImpl.java
index aad8e32..26e0e4a 100644
--- a/src/org/torproject/descriptor/impl/TorperfResultImpl.java
+++ b/src/org/torproject/descriptor/impl/TorperfResultImpl.java
@@ -79,60 +79,85 @@ public class TorperfResultImpl extends DescriptorImpl
String key = keyValueParts[0];
this.markKeyAsParsed(key, line);
String value = keyValueParts[1];
- if (key.equals("SOURCE")) {
+ switch (key) {
+ case "SOURCE":
this.parseSource(value, keyValue, line);
- } else if (key.equals("FILESIZE")) {
+ break;
+ case "FILESIZE":
this.parseFileSize(value, keyValue, line);
- } else if (key.equals("START")) {
+ break;
+ case "START":
this.parseStart(value, keyValue, line);
- } else if (key.equals("SOCKET")) {
+ break;
+ case "SOCKET":
this.parseSocket(value, keyValue, line);
- } else if (key.equals("CONNECT")) {
+ break;
+ case "CONNECT":
this.parseConnect(value, keyValue, line);
- } else if (key.equals("NEGOTIATE")) {
+ break;
+ case "NEGOTIATE":
this.parseNegotiate(value, keyValue, line);
- } else if (key.equals("REQUEST")) {
+ break;
+ case "REQUEST":
this.parseRequest(value, keyValue, line);
- } else if (key.equals("RESPONSE")) {
+ break;
+ case "RESPONSE":
this.parseResponse(value, keyValue, line);
- } else if (key.equals("DATAREQUEST")) {
+ break;
+ case "DATAREQUEST":
this.parseDataRequest(value, keyValue, line);
- } else if (key.equals("DATARESPONSE")) {
+ break;
+ case "DATARESPONSE":
this.parseDataResponse(value, keyValue, line);
- } else if (key.equals("DATACOMPLETE")) {
+ break;
+ case "DATACOMPLETE":
this.parseDataComplete(value, keyValue, line);
- } else if (key.equals("WRITEBYTES")) {
+ break;
+ case "WRITEBYTES":
this.parseWriteBytes(value, keyValue, line);
- } else if (key.equals("READBYTES")) {
+ break;
+ case "READBYTES":
this.parseReadBytes(value, keyValue, line);
- } else if (key.equals("DIDTIMEOUT")) {
+ break;
+ case "DIDTIMEOUT":
this.parseDidTimeout(value, keyValue, line);
- } else if (key.startsWith("DATAPERC")) {
- this.parseDataPercentile(value, keyValue, line);
- } else if (key.equals("LAUNCH")) {
+ break;
+ case "LAUNCH":
this.parseLaunch(value, keyValue, line);
- } else if (key.equals("USED_AT")) {
+ break;
+ case "USED_AT":
this.parseUsedAt(value, keyValue, line);
- } else if (key.equals("PATH")) {
+ break;
+ case "PATH":
this.parsePath(value, keyValue, line);
- } else if (key.equals("BUILDTIMES")) {
+ break;
+ case "BUILDTIMES":
this.parseBuildTimes(value, keyValue, line);
- } else if (key.equals("TIMEOUT")) {
+ break;
+ case "TIMEOUT":
this.parseTimeout(value, keyValue, line);
- } else if (key.equals("QUANTILE")) {
+ break;
+ case "QUANTILE":
this.parseQuantile(value, keyValue, line);
- } else if (key.equals("CIRC_ID")) {
+ break;
+ case "CIRC_ID":
this.parseCircId(value, keyValue, line);
- } else if (key.equals("USED_BY")) {
+ break;
+ case "USED_BY":
this.parseUsedBy(value, keyValue, line);
- } else if (this.failUnrecognizedDescriptorLines) {
- throw new DescriptorParseException("Unrecognized key '" + key
- + "' in line '" + line + "'.");
- } else {
- if (this.unrecognizedLines == null) {
- this.unrecognizedLines = new ArrayList<>();
+ break;
+ default:
+ if (key.startsWith("DATAPERC")) {
+ this.parseDataPercentile(value, keyValue, line);
+ } else if (this.failUnrecognizedDescriptorLines) {
+ throw new DescriptorParseException("Unrecognized key '" + key
+ + "' in line '" + line + "'.");
+ } else {
+ if (this.unrecognizedLines == null) {
+ this.unrecognizedLines = new ArrayList<>();
+ }
+ this.unrecognizedLines.add(line);
}
- this.unrecognizedLines.add(line);
}
}
this.checkAllRequiredKeysParsed(line);
1
0
[metrics-lib/master] Add change log entry for #17823, #17824, and #17830.
by karsten@torproject.org 25 Dec '15
by karsten@torproject.org 25 Dec '15
25 Dec '15
commit 623d149f810024045731cdb39d90bce0eea7151c
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Wed Dec 23 12:19:55 2015 +0100
Add change log entry for #17823, #17824, and #17830.
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 73e9a1e..cb49133 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,10 @@
- Support onion-key and ntor-onion-key cross certificates in server
descriptors.
+ * Minor changes
+ - Start using Java 7 features like the diamond operator and switch
+ on String, and use StringBuilder correctly in many places.
+
# Changes in version 1.0.0 - 2015-12-05
1
0
commit 77bea15579e1b4a9c50bbe4fa52afef220459643
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Tue Dec 22 17:25:02 2015 +0100
Use StringBuilder correctly.
We shouldn't call someStringBuilder.append(someString + "\n"), but
rather someStringBuilder.append(someString).append("\n"), or Java will
internally build another StringBuilder for the + part.
Suggested by iwakeh, implements #17830.
---
.../descriptor/impl/DescriptorCollectorImpl.java | 2 +-
.../impl/DirectoryKeyCertificateImpl.java | 6 +-
.../descriptor/impl/DirectorySignatureImpl.java | 6 +-
.../descriptor/impl/ExtraInfoDescriptorImpl.java | 2 +-
.../descriptor/impl/MicrodescriptorImpl.java | 6 +-
.../descriptor/impl/RelayDirectoryImpl.java | 16 +--
.../descriptor/impl/RelayNetworkStatusImpl.java | 12 +--
.../descriptor/impl/ServerDescriptorImpl.java | 2 +-
.../descriptor/impl/BridgeNetworkStatusTest.java | 10 +-
.../descriptor/impl/ConsensusBuilder.java | 42 ++++----
.../impl/ExtraInfoDescriptorImplTest.java | 108 ++++++++++----------
.../descriptor/impl/MicrodescriptorImplTest.java | 6 +-
.../impl/RelayNetworkStatusConsensusImplTest.java | 16 +--
.../impl/RelayNetworkStatusVoteImplTest.java | 64 ++++++------
.../descriptor/impl/ServerDescriptorImplTest.java | 62 +++++------
15 files changed, 180 insertions(+), 180 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java b/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java
index 49c7995..1a030ef 100644
--- a/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorCollectorImpl.java
@@ -124,7 +124,7 @@ public class DescriptorCollectorImpl implements DescriptorCollector {
huc.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
- sb.append(line + "\n");
+ sb.append(line).append("\n");
}
br.close();
}
diff --git a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
index fcbf3f7..2b7d3ea 100644
--- a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
@@ -101,9 +101,9 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl
default:
if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
switch (nextCrypto) {
@@ -125,7 +125,7 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else {
if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '"
diff --git a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
index 27e9cc9..8cf6589 100644
--- a/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectorySignatureImpl.java
@@ -56,14 +56,14 @@ public class DirectorySignatureImpl implements DirectorySignature {
line, parts[2 + algorithmOffset]);
} else if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
this.signature = cryptoString;
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else {
if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '"
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
index 36ff269..4fcf4c9 100644
--- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
@@ -246,7 +246,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
cryptoLines.add(line);
StringBuilder sb = new StringBuilder();
for (String cryptoLine : cryptoLines) {
- sb.append("\n" + cryptoLine);
+ sb.append("\n").append(cryptoLine);
}
String cryptoString = sb.toString().substring(1);
switch (nextCrypto) {
diff --git a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
index a70493d..d303fa0 100644
--- a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
@@ -92,9 +92,9 @@ public class MicrodescriptorImpl extends DescriptorImpl
default:
if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
if (nextCrypto.equals("onion-key")) {
@@ -105,7 +105,7 @@ public class MicrodescriptorImpl extends DescriptorImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else {
ParseHelper.parseKeyword(line, parts[0]);
if (this.failUnrecognizedDescriptorLines) {
diff --git a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
index 4d583aa..ac17f54 100644
--- a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
@@ -230,9 +230,9 @@ public class RelayDirectoryImpl extends DescriptorImpl
default:
if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
if (nextCrypto.equals("dir-signing-key") &&
@@ -244,7 +244,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else {
if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '"
@@ -318,9 +318,9 @@ public class RelayDirectoryImpl extends DescriptorImpl
nextCrypto = "directory-signature";
} else if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
if (nextCrypto.equals("directory-signature")) {
@@ -331,7 +331,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '" + line
+ "' in v2 network status.");
@@ -369,11 +369,11 @@ public class RelayDirectoryImpl extends DescriptorImpl
sb.append("-----BEGIN RSA PUBLIC KEY-----\n");
String keyString = partsNoOpt[1];
while (keyString.length() > 64) {
- sb.append(keyString.substring(0, 64) + "\n");
+ sb.append(keyString.substring(0, 64)).append("\n");
keyString = keyString.substring(64);
}
if (keyString.length() > 0) {
- sb.append(keyString + "\n");
+ sb.append(keyString).append("\n");
}
sb.append("-----END RSA PUBLIC KEY-----\n");
this.dirSigningKey = sb.toString();
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index a10ed7a..7788040 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -129,9 +129,9 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
default:
if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
if (nextCrypto.equals("dir-signing-key")) {
@@ -142,7 +142,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '" + line
+ "' in v2 network status.");
@@ -177,9 +177,9 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
nextCrypto = "directory-signature";
} else if (line.startsWith("-----BEGIN")) {
crypto = new StringBuilder();
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (line.startsWith("-----END")) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
String cryptoString = crypto.toString();
crypto = null;
if (nextCrypto.equals("directory-signature")) {
@@ -190,7 +190,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
}
nextCrypto = "";
} else if (crypto != null) {
- crypto.append(line + "\n");
+ crypto.append(line).append("\n");
} else if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '" + line
+ "' in v2 network status.");
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index 4ed311e..84ad2a1 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -179,7 +179,7 @@ public abstract class ServerDescriptorImpl extends DescriptorImpl
cryptoLines.add(line);
StringBuilder sb = new StringBuilder();
for (String cryptoLine : cryptoLines) {
- sb.append("\n" + cryptoLine);
+ sb.append("\n").append(cryptoLine);
}
String cryptoString = sb.toString().substring(1);
switch (nextCrypto) {
diff --git a/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java b/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
index d0e4cb7..0847e13 100644
--- a/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
+++ b/test/org/torproject/descriptor/impl/BridgeNetworkStatusTest.java
@@ -87,21 +87,21 @@ public class BridgeNetworkStatusTest {
}
private void appendHeader(StringBuilder sb) {
if (this.publishedLine != null) {
- sb.append(this.publishedLine + "\n");
+ sb.append(this.publishedLine).append("\n");
}
if (this.flagThresholdsLine != null) {
- sb.append(this.flagThresholdsLine + "\n");
+ sb.append(this.flagThresholdsLine).append("\n");
}
if (this.unrecognizedHeaderLine != null) {
- sb.append(this.unrecognizedHeaderLine + "\n");
+ sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
- sb.append(statusEntry + "\n");
+ sb.append(statusEntry).append("\n");
}
if (this.unrecognizedStatusEntryLine != null) {
- sb.append(this.unrecognizedStatusEntryLine + "\n");
+ sb.append(this.unrecognizedStatusEntryLine).append("\n");
}
}
}
diff --git a/test/org/torproject/descriptor/impl/ConsensusBuilder.java b/test/org/torproject/descriptor/impl/ConsensusBuilder.java
index 470523d..b9638fb 100644
--- a/test/org/torproject/descriptor/impl/ConsensusBuilder.java
+++ b/test/org/torproject/descriptor/impl/ConsensusBuilder.java
@@ -235,75 +235,75 @@ public class ConsensusBuilder {
}
private void appendHeader(StringBuilder sb) {
if (this.networkStatusVersionLine != null) {
- sb.append(this.networkStatusVersionLine + "\n");
+ sb.append(this.networkStatusVersionLine).append("\n");
}
if (this.voteStatusLine != null) {
- sb.append(this.voteStatusLine + "\n");
+ sb.append(this.voteStatusLine).append("\n");
}
if (this.consensusMethodLine != null) {
- sb.append(this.consensusMethodLine + "\n");
+ sb.append(this.consensusMethodLine).append("\n");
}
if (this.validAfterLine != null) {
- sb.append(this.validAfterLine + "\n");
+ sb.append(this.validAfterLine).append("\n");
}
if (this.freshUntilLine != null) {
- sb.append(this.freshUntilLine + "\n");
+ sb.append(this.freshUntilLine).append("\n");
}
if (this.validUntilLine != null) {
- sb.append(this.validUntilLine + "\n");
+ sb.append(this.validUntilLine).append("\n");
}
if (this.votingDelayLine != null) {
- sb.append(this.votingDelayLine + "\n");
+ sb.append(this.votingDelayLine).append("\n");
}
if (this.clientVersionsLine != null) {
- sb.append(this.clientVersionsLine + "\n");
+ sb.append(this.clientVersionsLine).append("\n");
}
if (this.serverVersionsLine != null) {
- sb.append(this.serverVersionsLine + "\n");
+ sb.append(this.serverVersionsLine).append("\n");
}
if (this.knownFlagsLine != null) {
- sb.append(this.knownFlagsLine + "\n");
+ sb.append(this.knownFlagsLine).append("\n");
}
if (this.paramsLine != null) {
- sb.append(this.paramsLine + "\n");
+ sb.append(this.paramsLine).append("\n");
}
if (this.unrecognizedHeaderLine != null) {
- sb.append(this.unrecognizedHeaderLine + "\n");
+ sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
private void appendDirSources(StringBuilder sb) {
for (String dirSource : this.dirSources) {
- sb.append(dirSource + "\n");
+ sb.append(dirSource).append("\n");
}
if (this.unrecognizedDirSourceLine != null) {
- sb.append(this.unrecognizedDirSourceLine + "\n");
+ sb.append(this.unrecognizedDirSourceLine).append("\n");
}
}
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
- sb.append(statusEntry + "\n");
+ sb.append(statusEntry).append("\n");
}
if (this.unrecognizedStatusEntryLine != null) {
- sb.append(this.unrecognizedStatusEntryLine + "\n");
+ sb.append(this.unrecognizedStatusEntryLine).append("\n");
}
}
private void appendFooter(StringBuilder sb) {
if (this.directoryFooterLine != null) {
- sb.append(this.directoryFooterLine + "\n");
+ sb.append(this.directoryFooterLine).append("\n");
}
if (this.bandwidthWeightsLine != null) {
- sb.append(this.bandwidthWeightsLine + "\n");
+ sb.append(this.bandwidthWeightsLine).append("\n");
}
if (this.unrecognizedFooterLine != null) {
- sb.append(this.unrecognizedFooterLine + "\n");
+ sb.append(this.unrecognizedFooterLine).append("\n");
}
}
private void appendDirectorySignatures(StringBuilder sb) {
for (String directorySignature : this.directorySignatures) {
- sb.append(directorySignature + "\n");
+ sb.append(directorySignature).append("\n");
}
if (this.unrecognizedDirectorySignatureLine != null) {
- sb.append(this.unrecognizedDirectorySignatureLine + "\n");
+ sb.append(this.unrecognizedDirectorySignatureLine).append("\n");
}
}
}
diff --git a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index 33540dc..6843196 100644
--- a/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -189,61 +189,61 @@ public class ExtraInfoDescriptorImplTest {
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.extraInfoLine != null) {
- sb.append(this.extraInfoLine + "\n");
+ sb.append(this.extraInfoLine).append("\n");
}
if (this.identityEd25519Lines != null) {
- sb.append(this.identityEd25519Lines + "\n");
+ sb.append(this.identityEd25519Lines).append("\n");
}
if (this.masterKeyEd25519Line != null) {
- sb.append(this.masterKeyEd25519Line + "\n");
+ sb.append(this.masterKeyEd25519Line).append("\n");
}
if (this.publishedLine != null) {
- sb.append(this.publishedLine + "\n");
+ sb.append(this.publishedLine).append("\n");
}
if (this.writeHistoryLine != null) {
- sb.append(this.writeHistoryLine + "\n");
+ sb.append(this.writeHistoryLine).append("\n");
}
if (this.readHistoryLine != null) {
- sb.append(this.readHistoryLine + "\n");
+ sb.append(this.readHistoryLine).append("\n");
}
if (this.dirreqWriteHistoryLine != null) {
- sb.append(this.dirreqWriteHistoryLine + "\n");
+ sb.append(this.dirreqWriteHistoryLine).append("\n");
}
if (this.dirreqReadHistoryLine != null) {
- sb.append(this.dirreqReadHistoryLine + "\n");
+ sb.append(this.dirreqReadHistoryLine).append("\n");
}
if (this.geoipDbDigestLine != null) {
- sb.append(this.geoipDbDigestLine + "\n");
+ sb.append(this.geoipDbDigestLine).append("\n");
}
if (this.geoip6DbDigestLine != null) {
- sb.append(this.geoip6DbDigestLine + "\n");
+ sb.append(this.geoip6DbDigestLine).append("\n");
}
if (this.geoipStatsLines != null) {
- sb.append(this.geoipStatsLines + "\n");
+ sb.append(this.geoipStatsLines).append("\n");
}
if (this.dirreqStatsLines != null) {
- sb.append(this.dirreqStatsLines + "\n");
+ sb.append(this.dirreqStatsLines).append("\n");
}
if (this.entryStatsLines != null) {
- sb.append(this.entryStatsLines + "\n");
+ sb.append(this.entryStatsLines).append("\n");
}
if (this.cellStatsLines != null) {
- sb.append(this.cellStatsLines + "\n");
+ sb.append(this.cellStatsLines).append("\n");
}
if (this.connBiDirectLine != null) {
- sb.append(this.connBiDirectLine + "\n");
+ sb.append(this.connBiDirectLine).append("\n");
}
if (this.exitStatsLines != null) {
- sb.append(this.exitStatsLines + "\n");
+ sb.append(this.exitStatsLines).append("\n");
}
if (this.bridgeStatsLines != null) {
- sb.append(this.bridgeStatsLines + "\n");
+ sb.append(this.bridgeStatsLines).append("\n");
}
if (this.hidservStatsLines != null) {
- sb.append(this.hidservStatsLines + "\n");
+ sb.append(this.hidservStatsLines).append("\n");
}
if (this.unrecognizedLine != null) {
- sb.append(this.unrecognizedLine + "\n");
+ sb.append(this.unrecognizedLine).append("\n");
}
if (this.nonAsciiLineBytes != null) {
try {
@@ -260,10 +260,10 @@ public class ExtraInfoDescriptorImplTest {
}
}
if (this.routerSigEd25519Line != null) {
- sb.append(this.routerSigEd25519Line + "\n");
+ sb.append(this.routerSigEd25519Line).append("\n");
}
if (this.routerSignatureLines != null) {
- sb.append(this.routerSignatureLines + "\n");
+ sb.append(this.routerSignatureLines).append("\n");
}
return sb.toString().getBytes();
}
@@ -298,10 +298,10 @@ public class ExtraInfoDescriptorImplTest {
private String buildGeoipStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.geoipStartTimeLine != null) {
- sb.append(this.geoipStartTimeLine + "\n");
+ sb.append(this.geoipStartTimeLine).append("\n");
}
if (this.geoipClientOriginsLine != null) {
- sb.append(this.geoipClientOriginsLine + "\n");
+ sb.append(this.geoipClientOriginsLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -440,43 +440,43 @@ public class ExtraInfoDescriptorImplTest {
private String buildDirreqStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.dirreqStatsEndLine != null) {
- sb.append(this.dirreqStatsEndLine + "\n");
+ sb.append(this.dirreqStatsEndLine).append("\n");
}
if (this.dirreqV3IpsLine != null) {
- sb.append(this.dirreqV3IpsLine + "\n");
+ sb.append(this.dirreqV3IpsLine).append("\n");
}
if (this.dirreqV2IpsLine != null) {
- sb.append(this.dirreqV2IpsLine + "\n");
+ sb.append(this.dirreqV2IpsLine).append("\n");
}
if (this.dirreqV3ReqsLine != null) {
- sb.append(this.dirreqV3ReqsLine + "\n");
+ sb.append(this.dirreqV3ReqsLine).append("\n");
}
if (this.dirreqV2ReqsLine != null) {
- sb.append(this.dirreqV2ReqsLine + "\n");
+ sb.append(this.dirreqV2ReqsLine).append("\n");
}
if (this.dirreqV3RespLine != null) {
- sb.append(this.dirreqV3RespLine + "\n");
+ sb.append(this.dirreqV3RespLine).append("\n");
}
if (this.dirreqV2RespLine != null) {
- sb.append(this.dirreqV2RespLine + "\n");
+ sb.append(this.dirreqV2RespLine).append("\n");
}
if (this.dirreqV2ShareLine != null) {
- sb.append(this.dirreqV2ShareLine + "\n");
+ sb.append(this.dirreqV2ShareLine).append("\n");
}
if (this.dirreqV3ShareLine != null) {
- sb.append(this.dirreqV3ShareLine + "\n");
+ sb.append(this.dirreqV3ShareLine).append("\n");
}
if (this.dirreqV3DirectDlLine != null) {
- sb.append(this.dirreqV3DirectDlLine + "\n");
+ sb.append(this.dirreqV3DirectDlLine).append("\n");
}
if (this.dirreqV2DirectDlLine != null) {
- sb.append(this.dirreqV2DirectDlLine + "\n");
+ sb.append(this.dirreqV2DirectDlLine).append("\n");
}
if (this.dirreqV3TunneledDlLine != null) {
- sb.append(this.dirreqV3TunneledDlLine + "\n");
+ sb.append(this.dirreqV3TunneledDlLine).append("\n");
}
if (this.dirreqV2TunneledDlLine != null) {
- sb.append(this.dirreqV2TunneledDlLine + "\n");
+ sb.append(this.dirreqV2TunneledDlLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -516,10 +516,10 @@ public class ExtraInfoDescriptorImplTest {
private String buildEntryStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.entryStatsEndLine != null) {
- sb.append(this.entryStatsEndLine + "\n");
+ sb.append(this.entryStatsEndLine).append("\n");
}
if (this.entryIpsLine != null) {
- sb.append(this.entryIpsLine + "\n");
+ sb.append(this.entryIpsLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -586,19 +586,19 @@ public class ExtraInfoDescriptorImplTest {
private String buildCellStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.cellStatsEndLine != null) {
- sb.append(this.cellStatsEndLine + "\n");
+ sb.append(this.cellStatsEndLine).append("\n");
}
if (this.cellProcessedCellsLine != null) {
- sb.append(this.cellProcessedCellsLine + "\n");
+ sb.append(this.cellProcessedCellsLine).append("\n");
}
if (this.cellQueuedCellsLine != null) {
- sb.append(this.cellQueuedCellsLine + "\n");
+ sb.append(this.cellQueuedCellsLine).append("\n");
}
if (this.cellTimeInQueueLine != null) {
- sb.append(this.cellTimeInQueueLine + "\n");
+ sb.append(this.cellTimeInQueueLine).append("\n");
}
if (this.cellCircuitsPerDecileLine != null) {
- sb.append(this.cellCircuitsPerDecileLine + "\n");
+ sb.append(this.cellCircuitsPerDecileLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -659,16 +659,16 @@ public class ExtraInfoDescriptorImplTest {
private String buildExitStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.exitStatsEndLine != null) {
- sb.append(this.exitStatsEndLine + "\n");
+ sb.append(this.exitStatsEndLine).append("\n");
}
if (this.exitKibibytesWrittenLine != null) {
- sb.append(this.exitKibibytesWrittenLine + "\n");
+ sb.append(this.exitKibibytesWrittenLine).append("\n");
}
if (this.exitKibibytesReadLine != null) {
- sb.append(this.exitKibibytesReadLine + "\n");
+ sb.append(this.exitKibibytesReadLine).append("\n");
}
if (this.exitStreamsOpenedLine != null) {
- sb.append(this.exitStreamsOpenedLine + "\n");
+ sb.append(this.exitStreamsOpenedLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -724,16 +724,16 @@ public class ExtraInfoDescriptorImplTest {
private String buildBridgeStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.bridgeStatsEndLine != null) {
- sb.append(this.bridgeStatsEndLine + "\n");
+ sb.append(this.bridgeStatsEndLine).append("\n");
}
if (this.bridgeIpsLine != null) {
- sb.append(this.bridgeIpsLine + "\n");
+ sb.append(this.bridgeIpsLine).append("\n");
}
if (this.bridgeIpVersionsLine != null) {
- sb.append(this.bridgeIpVersionsLine + "\n");
+ sb.append(this.bridgeIpVersionsLine).append("\n");
}
if (this.bridgeIpTransportsLine != null) {
- sb.append(this.bridgeIpTransportsLine + "\n");
+ sb.append(this.bridgeIpTransportsLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
@@ -783,13 +783,13 @@ public class ExtraInfoDescriptorImplTest {
private String buildHidservStatsLines() {
StringBuilder sb = new StringBuilder();
if (this.hidservStatsEndLine != null) {
- sb.append(this.hidservStatsEndLine + "\n");
+ sb.append(this.hidservStatsEndLine).append("\n");
}
if (this.hidservRendRelayedCellsLine != null) {
- sb.append(this.hidservRendRelayedCellsLine + "\n");
+ sb.append(this.hidservRendRelayedCellsLine).append("\n");
}
if (this.hidservDirOnionsSeenLine != null) {
- sb.append(this.hidservDirOnionsSeenLine + "\n");
+ sb.append(this.hidservDirOnionsSeenLine).append("\n");
}
String lines = sb.toString();
if (lines.endsWith("\n")) {
diff --git a/test/org/torproject/descriptor/impl/MicrodescriptorImplTest.java b/test/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
index ab4b8c8..abb51db 100644
--- a/test/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
@@ -39,13 +39,13 @@ public class MicrodescriptorImplTest {
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.onionKeyLines != null) {
- sb.append(this.onionKeyLines + "\n");
+ sb.append(this.onionKeyLines).append("\n");
}
if (this.ntorOnionKeyLine != null) {
- sb.append(this.ntorOnionKeyLine + "\n");
+ sb.append(this.ntorOnionKeyLine).append("\n");
}
if (this.idLine != null) {
- sb.append(this.idLine + "\n");
+ sb.append(this.idLine).append("\n");
}
return sb.toString().getBytes();
}
diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
index 1875774..42feb8b 100644
--- a/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
+++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImplTest.java
@@ -107,12 +107,12 @@ public class RelayNetworkStatusConsensusImplTest {
String dirSourceLine = "dir-source " + this.nickname + " "
+ this.identity + " " + this.hostName + " " + this.address + " "
+ this.dirPort + " " + this.orPort;
- sb.append(dirSourceLine + "\n");
+ sb.append(dirSourceLine).append("\n");
if (this.contactLine != null) {
- sb.append(this.contactLine + "\n");
+ sb.append(this.contactLine).append("\n");
}
if (this.voteDigestLine != null) {
- sb.append(this.voteDigestLine + "\n");
+ sb.append(this.voteDigestLine).append("\n");
}
String dirSourceWithTrailingNewLine = sb.toString();
String dirSource = dirSourceWithTrailingNewLine.substring(0,
@@ -218,18 +218,18 @@ public class RelayNetworkStatusConsensusImplTest {
String rLine = "r " + nickname + " " + fingerprintBase64 + " "
+ descriptorBase64 + " " + publishedString + " " + address + " "
+ orPort + " " + dirPort;
- sb.append(rLine + "\n");
+ sb.append(rLine).append("\n");
if (this.sLine != null) {
- sb.append(this.sLine + "\n");
+ sb.append(this.sLine).append("\n");
}
if (this.vLine != null) {
- sb.append(this.vLine + "\n");
+ sb.append(this.vLine).append("\n");
}
if (this.wLine != null) {
- sb.append(this.wLine + "\n");
+ sb.append(this.wLine).append("\n");
}
if (this.pLine != null) {
- sb.append(this.pLine + "\n");
+ sb.append(this.pLine).append("\n");
}
String statusEntryWithTrailingNewLine = sb.toString();
String statusEntry = statusEntryWithTrailingNewLine.substring(0,
diff --git a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
index 34e7721..c6b2fc7 100644
--- a/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
+++ b/test/org/torproject/descriptor/impl/RelayNetworkStatusVoteImplTest.java
@@ -378,108 +378,108 @@ public class RelayNetworkStatusVoteImplTest {
}
private void appendHeader(StringBuilder sb) {
if (this.networkStatusVersionLine != null) {
- sb.append(this.networkStatusVersionLine + "\n");
+ sb.append(this.networkStatusVersionLine).append("\n");
}
if (this.voteStatusLine != null) {
- sb.append(this.voteStatusLine + "\n");
+ sb.append(this.voteStatusLine).append("\n");
}
if (this.consensusMethodsLine != null) {
- sb.append(this.consensusMethodsLine + "\n");
+ sb.append(this.consensusMethodsLine).append("\n");
}
if (this.publishedLine != null) {
- sb.append(this.publishedLine + "\n");
+ sb.append(this.publishedLine).append("\n");
}
if (this.validAfterLine != null) {
- sb.append(this.validAfterLine + "\n");
+ sb.append(this.validAfterLine).append("\n");
}
if (this.freshUntilLine != null) {
- sb.append(this.freshUntilLine + "\n");
+ sb.append(this.freshUntilLine).append("\n");
}
if (this.validUntilLine != null) {
- sb.append(this.validUntilLine + "\n");
+ sb.append(this.validUntilLine).append("\n");
}
if (this.votingDelayLine != null) {
- sb.append(this.votingDelayLine + "\n");
+ sb.append(this.votingDelayLine).append("\n");
}
if (this.clientVersionsLine != null) {
- sb.append(this.clientVersionsLine + "\n");
+ sb.append(this.clientVersionsLine).append("\n");
}
if (this.serverVersionsLine != null) {
- sb.append(this.serverVersionsLine + "\n");
+ sb.append(this.serverVersionsLine).append("\n");
}
if (this.knownFlagsLine != null) {
- sb.append(this.knownFlagsLine + "\n");
+ sb.append(this.knownFlagsLine).append("\n");
}
if (this.flagThresholdsLine != null) {
- sb.append(this.flagThresholdsLine + "\n");
+ sb.append(this.flagThresholdsLine).append("\n");
}
if (this.paramsLine != null) {
- sb.append(this.paramsLine + "\n");
+ sb.append(this.paramsLine).append("\n");
}
if (this.unrecognizedHeaderLine != null) {
- sb.append(this.unrecognizedHeaderLine + "\n");
+ sb.append(this.unrecognizedHeaderLine).append("\n");
}
}
private void appendDirSource(StringBuilder sb) {
if (this.dirSourceLine != null) {
- sb.append(this.dirSourceLine + "\n");
+ sb.append(this.dirSourceLine).append("\n");
}
if (this.contactLine != null) {
- sb.append(this.contactLine + "\n");
+ sb.append(this.contactLine).append("\n");
}
if (this.legacyDirKeyLine != null) {
- sb.append(this.legacyDirKeyLine + "\n");
+ sb.append(this.legacyDirKeyLine).append("\n");
}
if (this.dirKeyCertificateVersionLine != null) {
- sb.append(this.dirKeyCertificateVersionLine + "\n");
+ sb.append(this.dirKeyCertificateVersionLine).append("\n");
}
if (this.fingerprintLine != null) {
- sb.append(this.fingerprintLine + "\n");
+ sb.append(this.fingerprintLine).append("\n");
}
if (this.dirKeyPublishedLine != null) {
- sb.append(this.dirKeyPublishedLine + "\n");
+ sb.append(this.dirKeyPublishedLine).append("\n");
}
if (this.dirKeyExpiresLine != null) {
- sb.append(this.dirKeyExpiresLine + "\n");
+ sb.append(this.dirKeyExpiresLine).append("\n");
}
if (this.dirIdentityKeyLines != null) {
- sb.append(this.dirIdentityKeyLines + "\n");
+ sb.append(this.dirIdentityKeyLines).append("\n");
}
if (this.dirSigningKeyLines != null) {
- sb.append(this.dirSigningKeyLines + "\n");
+ sb.append(this.dirSigningKeyLines).append("\n");
}
if (this.dirKeyCrosscertLines != null) {
- sb.append(this.dirKeyCrosscertLines + "\n");
+ sb.append(this.dirKeyCrosscertLines).append("\n");
}
if (this.dirKeyCertificationLines != null) {
- sb.append(this.dirKeyCertificationLines + "\n");
+ sb.append(this.dirKeyCertificationLines).append("\n");
}
if (this.unrecognizedDirSourceLine != null) {
- sb.append(this.unrecognizedDirSourceLine + "\n");
+ sb.append(this.unrecognizedDirSourceLine).append("\n");
}
}
private void appendStatusEntries(StringBuilder sb) {
for (String statusEntry : this.statusEntries) {
- sb.append(statusEntry + "\n");
+ sb.append(statusEntry).append("\n");
}
if (this.unrecognizedStatusEntryLine != null) {
- sb.append(this.unrecognizedStatusEntryLine + "\n");
+ sb.append(this.unrecognizedStatusEntryLine).append("\n");
}
}
private void appendFooter(StringBuilder sb) {
if (this.directoryFooterLine != null) {
- sb.append(this.directoryFooterLine + "\n");
+ sb.append(this.directoryFooterLine).append("\n");
}
if (this.unrecognizedFooterLine != null) {
- sb.append(this.unrecognizedFooterLine + "\n");
+ sb.append(this.unrecognizedFooterLine).append("\n");
}
}
private void appendDirectorySignature(StringBuilder sb) {
if (this.directorySignatureLines != null) {
- sb.append(directorySignatureLines + "\n");
+ sb.append(directorySignatureLines).append("\n");
}
if (this.unrecognizedDirectorySignatureLine != null) {
- sb.append(this.unrecognizedDirectorySignatureLine + "\n");
+ sb.append(this.unrecognizedDirectorySignatureLine).append("\n");
}
}
}
diff --git a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index 41be8ea..292afce 100644
--- a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -256,85 +256,85 @@ public class ServerDescriptorImplTest {
private byte[] buildDescriptor() {
StringBuilder sb = new StringBuilder();
if (this.routerLine != null) {
- sb.append(this.routerLine + "\n");
+ sb.append(this.routerLine).append("\n");
}
if (this.identityEd25519Lines != null) {
- sb.append(this.identityEd25519Lines + "\n");
+ sb.append(this.identityEd25519Lines).append("\n");
}
if (this.masterKeyEd25519Line != null) {
- sb.append(this.masterKeyEd25519Line + "\n");
+ sb.append(this.masterKeyEd25519Line).append("\n");
}
if (this.bandwidthLine != null) {
- sb.append(this.bandwidthLine + "\n");
+ sb.append(this.bandwidthLine).append("\n");
}
if (this.platformLine != null) {
- sb.append(this.platformLine + "\n");
+ sb.append(this.platformLine).append("\n");
}
if (this.publishedLine != null) {
- sb.append(this.publishedLine + "\n");
+ sb.append(this.publishedLine).append("\n");
}
if (this.fingerprintLine != null) {
- sb.append(this.fingerprintLine + "\n");
+ sb.append(this.fingerprintLine).append("\n");
}
if (this.hibernatingLine != null) {
- sb.append(this.hibernatingLine + "\n");
+ sb.append(this.hibernatingLine).append("\n");
}
if (this.uptimeLine != null) {
- sb.append(this.uptimeLine + "\n");
+ sb.append(this.uptimeLine).append("\n");
}
if (this.onionKeyLines != null) {
- sb.append(this.onionKeyLines + "\n");
+ sb.append(this.onionKeyLines).append("\n");
}
if (this.signingKeyLines != null) {
- sb.append(this.signingKeyLines + "\n");
+ sb.append(this.signingKeyLines).append("\n");
}
if (this.onionKeyCrosscertLines != null) {
- sb.append(this.onionKeyCrosscertLines + "\n");
+ sb.append(this.onionKeyCrosscertLines).append("\n");
}
if (this.ntorOnionKeyCrosscertLines != null) {
- sb.append(this.ntorOnionKeyCrosscertLines + "\n");
+ sb.append(this.ntorOnionKeyCrosscertLines).append("\n");
}
if (this.exitPolicyLines != null) {
- sb.append(this.exitPolicyLines + "\n");
+ sb.append(this.exitPolicyLines).append("\n");
}
if (this.contactLine != null) {
- sb.append(this.contactLine + "\n");
+ sb.append(this.contactLine).append("\n");
}
if (this.familyLine != null) {
- sb.append(this.familyLine + "\n");
+ sb.append(this.familyLine).append("\n");
}
if (this.readHistoryLine != null) {
- sb.append(this.readHistoryLine + "\n");
+ sb.append(this.readHistoryLine).append("\n");
}
if (this.writeHistoryLine != null) {
- sb.append(this.writeHistoryLine + "\n");
+ sb.append(this.writeHistoryLine).append("\n");
}
if (this.eventdnsLine != null) {
- sb.append(this.eventdnsLine + "\n");
+ sb.append(this.eventdnsLine).append("\n");
}
if (this.cachesExtraInfoLine != null) {
- sb.append(this.cachesExtraInfoLine + "\n");
+ sb.append(this.cachesExtraInfoLine).append("\n");
}
if (this.extraInfoDigestLine != null) {
- sb.append(this.extraInfoDigestLine + "\n");
+ sb.append(this.extraInfoDigestLine).append("\n");
}
if (this.hiddenServiceDirLine != null) {
- sb.append(this.hiddenServiceDirLine + "\n");
+ sb.append(this.hiddenServiceDirLine).append("\n");
}
if (this.protocolsLine != null) {
- sb.append(this.protocolsLine + "\n");
+ sb.append(this.protocolsLine).append("\n");
}
if (this.allowSingleHopExitsLine != null) {
- sb.append(this.allowSingleHopExitsLine + "\n");
+ sb.append(this.allowSingleHopExitsLine).append("\n");
}
if (this.ipv6PolicyLine != null) {
- sb.append(this.ipv6PolicyLine + "\n");
+ sb.append(this.ipv6PolicyLine).append("\n");
}
if (this.ntorOnionKeyLine != null) {
- sb.append(this.ntorOnionKeyLine + "\n");
+ sb.append(this.ntorOnionKeyLine).append("\n");
}
if (this.unrecognizedLine != null) {
- sb.append(this.unrecognizedLine + "\n");
+ sb.append(this.unrecognizedLine).append("\n");
}
if (this.nonAsciiLineBytes != null) {
try {
@@ -351,10 +351,10 @@ public class ServerDescriptorImplTest {
}
}
if (this.routerSigEd25519Line != null) {
- sb.append(this.routerSigEd25519Line + "\n");
+ sb.append(this.routerSigEd25519Line).append("\n");
}
if (this.routerSignatureLines != null) {
- sb.append(this.routerSignatureLines + "\n");
+ sb.append(this.routerSignatureLines).append("\n");
}
return sb.toString().getBytes();
}
@@ -1377,7 +1377,7 @@ public class ServerDescriptorImplTest {
unrecognizedLines.add("-----END RSA PUBLIC KEY-----");
StringBuilder sb = new StringBuilder();
for (String line : unrecognizedLines) {
- sb.append("\n" + line);
+ sb.append("\n").append(line);
}
ServerDescriptor descriptor = DescriptorBuilder.
createWithUnrecognizedLine(sb.toString().substring(1), false);
@@ -1398,7 +1398,7 @@ public class ServerDescriptorImplTest {
unrecognizedLines.add("-----END RSA PUBLIC KEY-----");
StringBuilder sb = new StringBuilder();
for (String line : unrecognizedLines) {
- sb.append("\n" + line);
+ sb.append("\n").append(line);
}
ServerDescriptor descriptor = DescriptorBuilder.
createWithUnrecognizedLine(sb.toString().substring(1), false);
1
0
commit 9a901aaa01eb3c362cc84836b54307b32f44295b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Dec 23 07:24:59 2015 -0500
changes file correction
---
changes/bug17923 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/changes/bug17923 b/changes/bug17923
index 48026a5..ea39960 100644
--- a/changes/bug17923
+++ b/changes/bug17923
@@ -1,4 +1,4 @@
o Minor bugfixes:
- - Add an #endif to configure.ac so that we correctly detect
+ - Remove an #endif from configure.ac so that we correctly detect
the presence of in6_addr.s6_addr32. Fixes bug 17923; bugfix on
0.2.0.13-alpha.
1
0
commit 2b9b694410fb0a6078290ed1652df608950a25cc
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Tue Dec 22 20:46:15 2015 -0500
Remove config.log from CLEANFILES
Fixes bug 17924; bugfix on 0.2.4.1-alpha.
In ddf5020ea8d51, we added config.log to CLEANFILES in doc/Makefile.am
so that distcheck would be happy about the presence of doc/config.log.
But when we moved to nonrecursie makefiles in 2a4a1496241d6, we
accidentally left that filename unchanged, so that it referred to
config.log instead.
Patch from cypherpunks.
---
changes/bug17924 | 4 ++++
doc/include.am | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/changes/bug17924 b/changes/bug17924
new file mode 100644
index 0000000..aa5cf58
--- /dev/null
+++ b/changes/bug17924
@@ -0,0 +1,4 @@
+ o Minor bugfixes (makefile):
+ - Remove config.log only from make distclean, not from
+ make clean. Fixes bug 17924; bugfix on 0.2.4.1-alpha.
+
diff --git a/doc/include.am b/doc/include.am
index 01a5ef2..7164a4b 100644
--- a/doc/include.am
+++ b/doc/include.am
@@ -90,5 +90,5 @@ doc/tor-gencert.1: doc/tor-gencert.1.in
doc/tor-resolve.1: doc/tor-resolve.1.in
doc/torify.1: doc/torify.1.in
-CLEANFILES+= $(asciidoc_product) config.log
+CLEANFILES+= $(asciidoc_product)
DISTCLEANFILES+= $(html_in) $(man_in)
1
0
23 Dec '15
commit 00fbe591a12c86e93f73a8a56da4a9157844f5a1
Author: Georg Koppen <gk(a)torproject.org>
Date: Wed Dec 23 08:03:04 2015 +0000
Adding Cooper Quintin's key
---
gitian/gpg/https-everywhere.gpg | Bin 112546 -> 188424 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/gitian/gpg/https-everywhere.gpg b/gitian/gpg/https-everywhere.gpg
index 96a2f45..43aa4e4 100644
Binary files a/gitian/gpg/https-everywhere.gpg and b/gitian/gpg/https-everywhere.gpg differ
1
0
23 Dec '15
commit 5a518270be8c4a170134d41096927f0cd0fcf3d0
Author: Georg Koppen <gk(a)torproject.org>
Date: Wed Dec 23 08:03:04 2015 +0000
Adding Cooper Quintin's key
---
gitian/gpg/https-everywhere.gpg | Bin 112546 -> 188424 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/gitian/gpg/https-everywhere.gpg b/gitian/gpg/https-everywhere.gpg
index 96a2f45..43aa4e4 100644
Binary files a/gitian/gpg/https-everywhere.gpg and b/gitian/gpg/https-everywhere.gpg differ
1
0
commit 77a249124635ee8ac4d62698433aebffa8a1b928
Author: Georg Koppen <gk(a)torproject.org>
Date: Wed Dec 23 08:03:04 2015 +0000
Adding Cooper Quintin's key
---
gitian/gpg/https-everywhere.gpg | Bin 112546 -> 188424 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/gitian/gpg/https-everywhere.gpg b/gitian/gpg/https-everywhere.gpg
index 96a2f45..43aa4e4 100644
Binary files a/gitian/gpg/https-everywhere.gpg and b/gitian/gpg/https-everywhere.gpg differ
1
0
commit d0c209c51d856ee78cca1e4ee337d10155a93916
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Tue Dec 22 20:37:02 2015 -0500
Remove extraneous #endif in configure.ac
This will fix the detection of struct in6_addr.s6_addr32 and others
Found and fixed by cypherpunks; bug 17923; bugfix on f948caad7b5bd
---
changes/bug17923 | 4 ++++
configure.ac | 1 -
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/changes/bug17923 b/changes/bug17923
new file mode 100644
index 0000000..48026a5
--- /dev/null
+++ b/changes/bug17923
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Add an #endif to configure.ac so that we correctly detect
+ the presence of in6_addr.s6_addr32. Fixes bug 17923; bugfix on
+ 0.2.0.13-alpha.
diff --git a/configure.ac b/configure.ac
index 2f75568..bf6d7f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1130,7 +1130,6 @@ AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct s
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
-#endif
])
AC_CHECK_TYPES([rlim_t], , ,
1
0