mirror of
https://github.com/torproject/metrics-lib.git
synced 2025-02-12 04:50:40 +00:00
Clear sets used to validate at-most-once/exactly-once keywords.
Related to 5caa384. Similarly, keeping these sets around just wastes heap space.
This commit is contained in:
parent
c439d346b9
commit
f3a170fb74
@ -33,7 +33,7 @@ public class DirSourceEntryImpl implements DirSourceEntry {
|
||||
failUnrecognizedDescriptorLines;
|
||||
this.initializeKeywords();
|
||||
this.parseDirSourceEntryBytes();
|
||||
this.checkKeywords();
|
||||
this.checkAndClearKeywords();
|
||||
}
|
||||
|
||||
private SortedSet<String> exactlyOnceKeywords, atMostOnceKeywords;
|
||||
@ -63,11 +63,13 @@ public class DirSourceEntryImpl implements DirSourceEntry {
|
||||
this.atMostOnceKeywords.remove(keyword);
|
||||
}
|
||||
|
||||
private void checkKeywords() throws DescriptorParseException {
|
||||
private void checkAndClearKeywords() throws DescriptorParseException {
|
||||
if (!this.exactlyOnceKeywords.isEmpty()) {
|
||||
throw new DescriptorParseException("dir-source does not contain a '"
|
||||
+ this.exactlyOnceKeywords.first() + "' line.");
|
||||
}
|
||||
this.exactlyOnceKeywords = null;
|
||||
this.atMostOnceKeywords = null;
|
||||
}
|
||||
|
||||
private void parseDirSourceEntryBytes()
|
||||
|
@ -33,7 +33,7 @@ public class ExitListEntryImpl implements ExitListEntry {
|
||||
failUnrecognizedDescriptorLines;
|
||||
this.initializeKeywords();
|
||||
this.parseExitListEntryBytes();
|
||||
this.checkKeywords();
|
||||
this.checkAndClearKeywords();
|
||||
}
|
||||
|
||||
private SortedSet<String> exactlyOnceKeywords;
|
||||
@ -54,11 +54,12 @@ public class ExitListEntryImpl implements ExitListEntry {
|
||||
this.exactlyOnceKeywords.remove(keyword);
|
||||
}
|
||||
|
||||
private void checkKeywords() throws DescriptorParseException {
|
||||
private void checkAndClearKeywords() throws DescriptorParseException {
|
||||
for (String missingKeyword : this.exactlyOnceKeywords) {
|
||||
throw new DescriptorParseException("Missing '" + missingKeyword
|
||||
+ "' line in exit list entry.");
|
||||
}
|
||||
this.exactlyOnceKeywords = null;
|
||||
}
|
||||
|
||||
private void parseExitListEntryBytes()
|
||||
|
@ -39,6 +39,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
|
||||
failUnrecognizedDescriptorLines;
|
||||
this.initializeKeywords();
|
||||
this.parseStatusEntryBytes();
|
||||
this.clearAtMostOnceKeywords();
|
||||
}
|
||||
|
||||
private SortedSet<String> atMostOnceKeywords;
|
||||
@ -218,6 +219,10 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearAtMostOnceKeywords() {
|
||||
this.atMostOnceKeywords = null;
|
||||
}
|
||||
|
||||
private String nickname;
|
||||
public String getNickname() {
|
||||
return this.nickname;
|
||||
|
Loading…
x
Reference in New Issue
Block a user