[tor-commits] [metrics-lib/release] Fix bug in newly simplified method.

karsten at torproject.org karsten at torproject.org
Wed Jun 7 07:06:30 UTC 2017


commit 823fa496ce2b4f32f791fe7fd1859e67af068d3a
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Sun Jun 4 17:37:18 2017 +0200

    Fix bug in newly simplified method.
---
 src/main/java/org/torproject/descriptor/impl/ParseHelper.java     | 3 +++
 .../torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java   | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
index cfd3724..e89b59e 100644
--- a/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
+++ b/src/main/java/org/torproject/descriptor/impl/ParseHelper.java
@@ -318,6 +318,9 @@ public class ParseHelper {
 
   protected static SortedMap<String, Integer>
       convertCommaSeparatedKeyIntegerValueList(String validatedString) {
+    if (null == validatedString) {
+      return null;
+    }
     KeyValueMap<Integer> result = new KeyValueMap<>(Integer.class);
     if (!validatedString.isEmpty()) {
       try {
diff --git a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
index 2e7bbc6..3d8c033 100644
--- a/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/ExtraInfoDescriptorImplTest.java
@@ -6,6 +6,7 @@ package org.torproject.descriptor.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import org.torproject.descriptor.BridgeExtraInfoDescriptor;
@@ -1366,6 +1367,13 @@ public class ExtraInfoDescriptorImplTest {
         + "u=1744");
   }
 
+  @Test()
+  public void testDirreqV3ReqsNull() throws DescriptorParseException {
+    ExtraInfoDescriptor eid =
+        DirreqStatsBuilder.createWithDirreqV3ReqsLine(null);
+    assertNull(eid.getDirreqV3Reqs());
+  }
+
   @Test(expected = DescriptorParseException.class)
   public void testDirreqV2ReqsNoNumber()
       throws DescriptorParseException {





More information about the tor-commits mailing list