Skip to content

Commit

Permalink
Common: fix pattern matching against null in ScrambleMapFunction (close
Browse files Browse the repository at this point in the history
  • Loading branch information
benjben committed Sep 9, 2020
1 parent 0725232 commit eaa7c9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import io.circe.jackson._
import io.circe.syntax._

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.{ArrayNode, ObjectNode, TextNode}
import com.fasterxml.jackson.databind.node.{ArrayNode, NullNode, ObjectNode, TextNode}
import com.fasterxml.jackson.databind.ObjectMapper

import com.jayway.jsonpath.{Configuration, JsonPath => JJsonPath}
Expand Down Expand Up @@ -306,8 +306,9 @@ private final case class ScrambleMapFunction(
)
arr.add(newValue)
case default: AnyRef => arr.add(default)
case null => arr.add(NullNode.getInstance())
}
arr
case default: AnyRef => default
case _ => currentValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidatedMatcher
| {
| "schema": "iglu:com.test/array/jsonschema/1-0-0",
| "data": {
| "field" : ["hello", "world"]
| "field" : ["hello", "world"],
| "field2" : null
| }
| }
| ]
Expand Down Expand Up @@ -347,6 +348,11 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidatedMatcher
schemaCriterion = SchemaCriterion("com.test", "array", "jsonschema", 1, 0, 0),
jsonPath = "$.field"
),
PiiJson(
fieldMutator = JsonMutators("contexts"),
schemaCriterion = SchemaCriterion("com.test", "array", "jsonschema", 1, 0, 0),
jsonPath = "$.field2"
),
PiiJson(
fieldMutator = JsonMutators("unstruct_event"),
schemaCriterion = SchemaCriterion("com.mailgun", "message_clicked", "jsonschema", 1, 0, 0),
Expand Down

0 comments on commit eaa7c9d

Please sign in to comment.