Skip to content

Commit 9405350

Browse files
committed
Clean up for the Fix KafkaNull for JSONConverters
Fixes: #2924
1 parent 0c51f98 commit 9405350

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

spring-kafka/src/main/java/org/springframework/kafka/support/converter/ByteArrayJsonMessageConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*
3232
* @author Gary Russell
3333
* @author Vladimir Loginov
34+
*
3435
* @since 2.3
3536
*
3637
*/
@@ -48,7 +49,7 @@ protected Object convertPayload(Message<?> message) {
4849
try {
4950
return message.getPayload() instanceof KafkaNull
5051
? null
51-
: getObjectMapper().writeValueAsBytes(message.getPayload());
52+
: getObjectMapper().writeValueAsBytes(message.getPayload());
5253
}
5354
catch (JsonProcessingException e) {
5455
throw new ConversionException("Failed to convert to JSON", message, e);

spring-kafka/src/main/java/org/springframework/kafka/support/converter/BytesJsonMessageConverter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*
3434
* @author Gary Russell
3535
* @author Vladimir Loginov
36+
*
3637
* @since 2.1.7
3738
*
3839
*/

spring-kafka/src/test/java/org/springframework/kafka/annotation/BatchListenerConversionTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ public void testBatchOfPojoMessages(@Autowired KafkaAdmin admin) throws Exceptio
129129
assertThat(listener.received.size()).isGreaterThan(0);
130130
assertThat(listener.received.get(0).getPayload()).isInstanceOf(Foo.class);
131131
assertThat(listener.received.get(0).getPayload().getBar()).isEqualTo("bar");
132-
assertThatNoException().isThrownBy(() -> this.template.send(
133-
new GenericMessage<>(KafkaNull.INSTANCE, Collections.singletonMap(KafkaHeaders.TOPIC, topic))));
134132
verify(admin, never()).clusterId();
133+
134+
assertThatNoException()
135+
.isThrownBy(() ->
136+
this.template.send(
137+
new GenericMessage<>(KafkaNull.INSTANCE,
138+
Collections.singletonMap(KafkaHeaders.TOPIC, topic))));
135139
}
136140

137141
@Test

0 commit comments

Comments
 (0)