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

[tor-commits] [metrics-lib/release] Ignore unknown fields in index.json.



commit fba9137499ef6255f040d134f488403cae214793
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Sat Nov 9 12:20:36 2019 +0100

    Ignore unknown fields in index.json.
    
    This is required for processing index.json files produced by CollecTor
    1.13.0 or higher. We don't need those newly added fields or any other
    fields added in the future. But we must not fail when fields are
    added.
---
 CHANGELOG.md                                                 | 5 ++++-
 src/main/java/org/torproject/descriptor/index/IndexNode.java | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99048e8..2fd361d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,7 @@
-# Changes in version 2.?.? - 2019-1?-??
+# Changes in version 2.9.1 - 2019-11-09
+
+ * Minor changes
+   - Do not fail when processing index.json files with unknown fields.
 
 
 # Changes in version 2.9.0 - 2019-11-01
diff --git a/src/main/java/org/torproject/descriptor/index/IndexNode.java b/src/main/java/org/torproject/descriptor/index/IndexNode.java
index b6855e3..9136b65 100644
--- a/src/main/java/org/torproject/descriptor/index/IndexNode.java
+++ b/src/main/java/org/torproject/descriptor/index/IndexNode.java
@@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
 import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
 
@@ -54,7 +55,8 @@ public class IndexNode {
       .setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
       .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
       .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
-      .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
+      .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
+      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
   /** The created date-time is exposed in JSON as 'index_created' field. */
   @JsonProperty("index_created")



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