[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Clear sets used to validate at-most-once/exactly-once keywords.



commit f3a170fb74e753d71d6c2513f4c09fc789286ad4
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Jun 17 20:32:55 2014 +0200

    Clear sets used to validate at-most-once/exactly-once keywords.
    
    Related to 5caa384.  Similarly, keeping these sets around just wastes heap
    space.
---
 src/org/torproject/descriptor/impl/DirSourceEntryImpl.java     |    6 ++++--
 src/org/torproject/descriptor/impl/ExitListEntryImpl.java      |    5 +++--
 src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java |    5 +++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
index bd97948..0156790 100644
--- a/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/DirSourceEntryImpl.java
@@ -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()
diff --git a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
index 958fd68..fc7d286 100644
--- a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
@@ -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()
diff --git a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
index 3962009..d8aa5f0 100644
--- a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
+++ b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java
@@ -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;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits