Skip to content

Commit

Permalink
JSON processing: fix regression bug due to which "tokenComparator" an…
Browse files Browse the repository at this point in the history
…d "algorithm" turned into mandatory fields
  • Loading branch information
gremid committed Mar 14, 2015
1 parent ac4deaf commit 90c4852
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static SimpleCollation read(InputStream inputStream) throws IOException {

Comparator<eu.interedition.collatex.Token> 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"))) {
Expand All @@ -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);
Expand Down

0 comments on commit 90c4852

Please sign in to comment.