Java 21
<spring-cloud-contract.version>4.1.3</spring-cloud-contract.version>
Describe the bug
When running the maven plugin, my contract.yaml has a bodyFromFile value.
This file is a .json containing (amongst other things) an array with values.
One of these value can be null
Sample
{
"rows": [
{
"values": [
"2023-10-19 08:39:55",
"B",
"N",
"",
"100",
"01",
1,
1369,
"100",
null,
null,
null
],
]
}
In the class DelegatingJsonVerifiable this method:
private static String wrapValueWithQuotes(Object value) {
return value instanceof String ? "\"" + stringWithEscapedQuotes(value) + "\"" : value.toString();
}
does not take into account that the value can be null - (value instanceof String is false => value.toString throws NPE
Java 21
<spring-cloud-contract.version>4.1.3</spring-cloud-contract.version>Describe the bug
When running the maven plugin, my
contract.yamlhas abodyFromFilevalue.This file is a
.jsoncontaining (amongst other things) an array with values.One of these value can be
nullSample
{ "rows": [ { "values": [ "2023-10-19 08:39:55", "B", "N", "", "100", "01", 1, 1369, "100", null, null, null ], ] }In the class
DelegatingJsonVerifiablethis method:does not take into account that the value can be null - (value instanceof String is false => value.toString throws NPE