Skip to content

Commit 0b22336

Browse files
committed
Fix Sonar Issue
1 parent 95fce11 commit 0b22336

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

spring-integration-kafka/src/main/java/org/springframework/integration/kafka/inbound/KafkaInboundGateway.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.springframework.kafka.support.converter.KafkaMessageHeaders;
4949
import org.springframework.kafka.support.converter.RecordMessageConverter;
5050
import org.springframework.messaging.Message;
51+
import org.springframework.messaging.MessageChannel;
5152
import org.springframework.messaging.MessageHeaders;
5253
import org.springframework.retry.RecoveryCallback;
5354
import org.springframework.retry.RetryCallback;
@@ -285,8 +286,9 @@ public void onMessage(ConsumerRecord<K, V> record, Acknowledgment acknowledgment
285286
setAttributesIfNecessary(record, message);
286287
}
287288
catch (RuntimeException e) {
288-
if (getErrorChannel() != null) {
289-
KafkaInboundGateway.this.messagingTemplate.send(getErrorChannel(), buildErrorMessage(null,
289+
MessageChannel errorChannel = getErrorChannel();
290+
if (errorChannel != null) {
291+
KafkaInboundGateway.this.messagingTemplate.send(errorChannel, buildErrorMessage(null,
290292
new ConversionException("Failed to convert to message", record, e)));
291293
}
292294
}

0 commit comments

Comments
 (0)