diff --git a/core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/MatcherExecutor.kt b/core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/MatcherExecutor.kt index 70c6eed7c0..8033f9814b 100755 --- a/core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/MatcherExecutor.kt +++ b/core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/MatcherExecutor.kt @@ -162,7 +162,7 @@ fun matchRegex( actual: Any?, mismatchFactory: MismatchFactory ): List { - val matches = if (actual is JsonValue.Null) false else safeToString(actual).matches(Regex(regex)) + val matches = if (actual == null || actual is JsonValue.Null) false else safeToString(actual).matches(Regex(regex)) logger.debug { "comparing ${valueOf(actual)} with regexp $regex at $path -> $matches" } return if (matches || expected is List<*> && actual is List<*> || diff --git a/core/matchers/src/test/groovy/au/com/dius/pact/core/matchers/MatcherExecutorSpec.groovy b/core/matchers/src/test/groovy/au/com/dius/pact/core/matchers/MatcherExecutorSpec.groovy index 7aa2e40711..320a9ece60 100755 --- a/core/matchers/src/test/groovy/au/com/dius/pact/core/matchers/MatcherExecutorSpec.groovy +++ b/core/matchers/src/test/groovy/au/com/dius/pact/core/matchers/MatcherExecutorSpec.groovy @@ -77,6 +77,7 @@ class MatcherExecutorSpec extends Specification { '100' | new JsonValue.Integer('20123'.chars) | '\\d+' || true json('"harry100"') | json('"20123happy"') | '[a-z0-9]+' || true json('"issue1316"') | JsonValue.Null.INSTANCE | '[a-z0-9]+' || false + json('"issue1316"') | null | '[a-z0-9]*' || false } @Unroll