[tor-commits] [onionoo/master] Avoid IllegalStateException when descriptors are missing.

karsten at torproject.org karsten at torproject.org
Wed Jul 11 13:14:58 UTC 2018


commit b6e3a1d51722f02f2d391295a676c7b241090213
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Wed Jul 11 09:35:07 2018 +0200

    Avoid IllegalStateException when descriptors are missing.
    
    A missing descriptor directory has caused an IllegalStateException
    when we attempted to write our parse history files. Let's be more
    careful about this case and skip this history file if there is no such
    directory.
    
    Fixes #26711.
---
 CHANGELOG.md                                                      | 2 ++
 src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca0142b..d4cfb82 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@
  * Minor changes
    - Index relays with no known country code or autonomous system
      number using the special values "xz" and "AS0" respectively.
+   - Avoid running into an IllegalStateException when CollecTor is
+     missing a whole descriptor directory.
 
 
 # Changes in version 6.0-1.14.0 - 2018-05-29
diff --git a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
index c19fabd..d00b8b2 100644
--- a/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
+++ b/src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
@@ -108,6 +108,11 @@ class DescriptorQueue {
     if (this.historyFile == null) {
       return;
     }
+    if (null == this.descriptors) {
+      log.debug("Not writing history file {}, because we did not read a single "
+          + "descriptor from {}.", this.historyFile, this.directory);
+      return;
+    }
     SortedMap<String, Long> excludedAndParsedFiles = new TreeMap<>();
     excludedAndParsedFiles.putAll(
         this.descriptorReader.getExcludedFiles());



More information about the tor-commits mailing list