[tor-commits] [metrics-lib/master] Clear parsed keywords after verifying them.
karsten at torproject.org
karsten at torproject.org
Sun Jun 1 09:46:37 UTC 2014
commit 5caa3848b0c09aed59333563e291ce616f419821
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Tue May 27 21:03:52 2014 +0200
Clear parsed keywords after verifying them.
No need to keep them around. That's just a waste of heap space.
---
src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java | 1 +
src/org/torproject/descriptor/impl/DescriptorImpl.java | 4 ++++
.../torproject/descriptor/impl/DirectoryKeyCertificateImpl.java | 1 +
src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java | 1 +
src/org/torproject/descriptor/impl/MicrodescriptorImpl.java | 1 +
src/org/torproject/descriptor/impl/RelayDirectoryImpl.java | 1 +
.../descriptor/impl/RelayNetworkStatusConsensusImpl.java | 1 +
src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java | 1 +
src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java | 1 +
src/org/torproject/descriptor/impl/ServerDescriptorImpl.java | 1 +
10 files changed, 13 insertions(+)
diff --git a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
index c4be80d..8ca4ea6 100644
--- a/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
+++ b/src/org/torproject/descriptor/impl/BridgePoolAssignmentImpl.java
@@ -43,6 +43,7 @@ public class BridgePoolAssignmentImpl extends DescriptorImpl
new String[] { "bridge-pool-assignment" }));
this.checkExactlyOnceKeywords(exactlyOnceKeywords);
this.checkFirstKeyword("bridge-pool-assignment");
+ this.clearParsedKeywords();
return;
}
diff --git a/src/org/torproject/descriptor/impl/DescriptorImpl.java b/src/org/torproject/descriptor/impl/DescriptorImpl.java
index ee50ec6..c4113be 100644
--- a/src/org/torproject/descriptor/impl/DescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/DescriptorImpl.java
@@ -319,5 +319,9 @@ public abstract class DescriptorImpl implements Descriptor {
return this.parsedKeywords.get(keyword);
}
}
+
+ protected void clearParsedKeywords() {
+ this.parsedKeywords = null;
+ }
}
diff --git a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
index 338f8e6..59846df 100644
--- a/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
+++ b/src/org/torproject/descriptor/impl/DirectoryKeyCertificateImpl.java
@@ -51,6 +51,7 @@ public class DirectoryKeyCertificateImpl extends DescriptorImpl
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("dir-key-certificate-version");
this.checkLastKeyword("dir-key-certification");
+ this.clearParsedKeywords();
}
private void parseDescriptorBytes() throws DescriptorParseException {
diff --git a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
index c67a040..a533113 100644
--- a/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ExtraInfoDescriptorImpl.java
@@ -81,6 +81,7 @@ public class ExtraInfoDescriptorImpl extends DescriptorImpl
this.checkKeywordsDependOn(exitStatsKeywords, "exit-stats-end");
this.checkKeywordsDependOn(bridgeStatsKeywords, "bridge-stats-end");
this.checkFirstKeyword("extra-info");
+ this.clearParsedKeywords();
return;
}
diff --git a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
index 15fb91e..30db583 100644
--- a/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/MicrodescriptorImpl.java
@@ -47,6 +47,7 @@ public class MicrodescriptorImpl extends DescriptorImpl
"ntor-onion-key,family,p,p6").split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("onion-key");
+ this.clearParsedKeywords();
return;
}
diff --git a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
index 03d727e..2426023 100644
--- a/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayDirectoryImpl.java
@@ -51,6 +51,7 @@ public class RelayDirectoryImpl extends DescriptorImpl
"dir-signing-key,running-routers,router-status".split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("signed-directory");
+ this.clearParsedKeywords();
}
private void calculateDigest() throws DescriptorParseException {
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
index d6babee..ff963e6 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusConsensusImpl.java
@@ -51,6 +51,7 @@ public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
+ "bandwidth-weights").split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("network-status-version");
+ this.clearParsedKeywords();
this.calculateDigest();
}
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index 78cacd0..6089fc7 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -48,6 +48,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
"dir-options,client-versions,server-versions".split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("network-status-version");
+ this.clearParsedKeywords();
this.calculateDigest();
}
diff --git a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
index c5ba980..d0d09f7 100644
--- a/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
+++ b/src/org/torproject/descriptor/impl/RelayNetworkStatusVoteImpl.java
@@ -54,6 +54,7 @@ public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
split(",")));
this.checkAtMostOnceKeywords(atMostOnceKeywords);
this.checkFirstKeyword("network-status-version");
+ this.clearParsedKeywords();
}
protected void parseHeader(byte[] headerBytes)
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index d1fcd28..52d49b0 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -57,6 +57,7 @@ public class ServerDescriptorImpl extends DescriptorImpl
throw new DescriptorParseException("Either keyword 'accept' or "
+ "'reject' must be contained at least once.");
}
+ this.clearParsedKeywords();
return;
}
More information about the tor-commits
mailing list