Skip to content

Commit

Permalink
Clean up for the Fix KafkaNull for JSONConverters
Browse files Browse the repository at this point in the history
Fixes: #2924
  • Loading branch information
artembilan committed Dec 8, 2023
1 parent 0c51f98 commit 9405350
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author Gary Russell
* @author Vladimir Loginov
*
* @since 2.3
*
*/
Expand All @@ -48,7 +49,7 @@ protected Object convertPayload(Message<?> message) {
try {
return message.getPayload() instanceof KafkaNull
? null
: getObjectMapper().writeValueAsBytes(message.getPayload());
: getObjectMapper().writeValueAsBytes(message.getPayload());
}
catch (JsonProcessingException e) {
throw new ConversionException("Failed to convert to JSON", message, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*
* @author Gary Russell
* @author Vladimir Loginov
*
* @since 2.1.7
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ public void testBatchOfPojoMessages(@Autowired KafkaAdmin admin) throws Exceptio
assertThat(listener.received.size()).isGreaterThan(0);
assertThat(listener.received.get(0).getPayload()).isInstanceOf(Foo.class);
assertThat(listener.received.get(0).getPayload().getBar()).isEqualTo("bar");
assertThatNoException().isThrownBy(() -> this.template.send(
new GenericMessage<>(KafkaNull.INSTANCE, Collections.singletonMap(KafkaHeaders.TOPIC, topic))));
verify(admin, never()).clusterId();

assertThatNoException()
.isThrownBy(() ->
this.template.send(
new GenericMessage<>(KafkaNull.INSTANCE,
Collections.singletonMap(KafkaHeaders.TOPIC, topic))));
}

@Test
Expand Down

0 comments on commit 9405350

Please sign in to comment.