Describe the bug
Given spring cloud contract 4.0.4 and a contract to simulate Kafka Null
import org.springframework.cloud.contract.spec.Contract
Contract.make {
description('kafka null')
label('triggerTombstoneEvent')
input {
triggeredBy('triggerTombstoneEvent()')
}
outputMessage {
sentTo('static-instrument')
headers {
header('kafka_messageKey', 'MY_KEY')
}
}
}
(note no body)
When I run this contract via the stub runner
@Autowired
private StubTrigger stubTrigger;
....
public void myTest() {
stubTrigger.trigger("triggerTombstoneEvent");
Then the StubRunnerExecutor.sendMessage does not handle a null body
java.lang.NullPointerException: Cannot invoke "org.springframework.cloud.contract.spec.internal.DslProperty.getClientValue()" because "body" is null
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.sendMessage(StubRunnerExecutor.java:254)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.triggerForDsls(StubRunnerExecutor.java:206)
at org.springframework.cloud.contract.stubrunner.StubRunnerExecutor.trigger(StubRunnerExecutor.java:192)
at org.springframework.cloud.contract.stubrunner.StubRunner.trigger(StubRunner.java:152)
at org.springframework.cloud.contract.stubrunner.BatchStubRunner.trigger(BatchStubRunner.java:133)
at uk.co.ii.staticinstrument.cucumber.CucumberStep.triggerFromStub(CucumberStep.java:113)
at uk.co.ii.staticinstrument.cucumber.CucumberStep.whenATombstoneEventArrives(CucumberStep.java:97)
at ✽.A tombstone event arrives(classpath:uk/co/ii/staticinstrument/cucumber/consumer.feature:5)
If we zoom into org.springframework.cloud.contract.stubrunner.StubRunnerExecutor the assumption here is body is not null:
private void sendMessage(Contract groovyDsl) {
OutputMessage outputMessage = groovyDsl.getOutputMessage();
DslProperty<?> body = outputMessage.getBody();
....
Object payload = null;
if (body.getClientValue() instanceof FromFileProperty) {
Could this be fixed to allow for a null body?
Describe the bug
Given spring cloud contract 4.0.4 and a contract to simulate Kafka Null
(note no body)
When I run this contract via the stub runner
Then the StubRunnerExecutor.sendMessage does not handle a null body
If we zoom into org.springframework.cloud.contract.stubrunner.StubRunnerExecutor the assumption here is body is not null:
Could this be fixed to allow for a null body?