From 90c4852b1ceba4991ece1a7c0d6403c8d470e5b3 Mon Sep 17 00:00:00 2001 From: Gregor Middell Date: Sat, 14 Mar 2015 09:10:22 +0100 Subject: [PATCH] JSON processing: fix regression bug due to which "tokenComparator" and "algorithm" turned into mandatory fields --- .../java/eu/interedition/collatex/tools/JsonProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collatex-tools/src/main/java/eu/interedition/collatex/tools/JsonProcessor.java b/collatex-tools/src/main/java/eu/interedition/collatex/tools/JsonProcessor.java index 8607601b6..6d35fc0cd 100644 --- a/collatex-tools/src/main/java/eu/interedition/collatex/tools/JsonProcessor.java +++ b/collatex-tools/src/main/java/eu/interedition/collatex/tools/JsonProcessor.java @@ -157,7 +157,7 @@ public static SimpleCollation read(InputStream inputStream) throws IOException { Comparator tokenComparator = null; final JsonValue tokenComparatorNode = collationObject.get("tokenComparator"); - if (tokenComparatorNode.getValueType() == JsonValue.ValueType.OBJECT) { + if (tokenComparatorNode != null && tokenComparatorNode.getValueType() == JsonValue.ValueType.OBJECT) { final JsonObject tokenComparatorObject = (JsonObject) tokenComparatorNode; try { if ("levenshtein".equals(tokenComparatorObject.getString("type"))) { @@ -174,7 +174,7 @@ public static SimpleCollation read(InputStream inputStream) throws IOException { CollationAlgorithm collationAlgorithm = null; final JsonValue collationAlgorithmNode = collationObject.get("algorithm"); - if (collationAlgorithmNode.getValueType() == JsonValue.ValueType.STRING) { + if (collationAlgorithmNode != null && collationAlgorithmNode.getValueType() == JsonValue.ValueType.STRING) { final String collationAlgorithmValue = ((JsonString) collationAlgorithmNode).getString(); if ("needleman-wunsch".equalsIgnoreCase(collationAlgorithmValue)) { collationAlgorithm = CollationAlgorithmFactory.needlemanWunsch(tokenComparator);