[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [collector/master] Fix possible NullPointerException.
commit 7af5f1e018269ae5900a0633a6e2f131053f5442
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed Sep 28 15:09:39 2016 +0200
Fix possible NullPointerException.
Spotted while writing tests for the bridgedescs module and also
reported independently as #20044.
---
.../org/torproject/collector/bridgedescs/BridgeSnapshotReader.java | 3 +++
.../collector/bridgedescs/SanitizedBridgesWriterTest.java | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
index 046db7d..683cb1c 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
@@ -153,6 +153,9 @@ public class BridgeSnapshotReader {
break;
}
}
+ if (firstLine == null) {
+ continue;
+ }
if (firstLine.startsWith("published ")
|| firstLine.startsWith("flag-thresholds ")
|| firstLine.startsWith("r ")) {
diff --git a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
index 0049bb6..8deeebc 100644
--- a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
+++ b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java
@@ -214,6 +214,12 @@ public class SanitizedBridgesWriterTest {
}
@Test
+ public void testServerDescriptorOnlyAnnotation() throws Exception {
+ this.defaultServerDescriptorBuilder.removeAllExcept("@purpose bridge");
+ this.runTest();
+ }
+
+ @Test
public void testServerDescriptorAdditionalAnnotation()
throws Exception {
this.defaultServerDescriptorBuilder.insertBeforeLineStartingWith(
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits