Closed fireplace009 closed 4 months ago
Java 21 <spring-cloud-contract.version>4.1.3</spring-cloud-contract.version>
<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
contract.yaml
bodyFromFile
.json
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:
DelegatingJsonVerifiable
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
Awesome !!! Thank you
Thank you for filing the issue :)
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 abodyFromFile
value. This file is a.json
containing (amongst other things) an array with values. One of these value can benull
Sample
In the class
DelegatingJsonVerifiable
this method:does not take into account that the value can be null - (value instanceof String is false => value.toString throws NPE