Skip to content

Commit 07a8b09

Browse files
garyrussellartembilan
authored andcommitted
Polishing for previous commit
- Modify the warning message if there is an error handler - move the void check to the assert instead of the if statment
1 parent 3a54827 commit 07a8b09

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-kafka/src/main/java/org/springframework/kafka/config/MethodKafkaListenerEndpoint.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ private String getReplyTopic() {
111111
SendTo ann = AnnotationUtils.getAnnotation(method, SendTo.class);
112112
if (ann != null) {
113113
if (method.getReturnType().equals(void.class)) {
114-
this.logger.warn("Method has a void return type; @SendTo is ignored");
114+
if (this.logger.isWarnEnabled()) {
115+
this.logger.warn("Method has a void return type; @SendTo is ignored" +
116+
(this.errorHandler == null ? "" : " unless the error handler returns a result"));
117+
}
115118
}
116119
String[] destinations = ann.value();
117120
if (destinations.length > 1) {
@@ -140,8 +143,9 @@ protected MessagingMessageListenerAdapter<K, V> createMessageListener(MessageLis
140143
MessagingMessageListenerAdapter<K, V> messageListener = createMessageListenerInstance(messageConverter);
141144
messageListener.setHandlerMethod(configureListenerAdapter(messageListener));
142145
String replyTopic = getReplyTopic();
143-
if (replyTopic != null && !getMethod().getReturnType().equals(void.class)) {
144-
Assert.state(getReplyTemplate() != null, "a KafkaTemplate is required to support replies");
146+
if (replyTopic != null) {
147+
Assert.state(getMethod().getReturnType().equals(void.class)
148+
|| getReplyTemplate() != null, "a KafkaTemplate is required to support replies");
145149
messageListener.setReplyTopic(replyTopic);
146150
}
147151
if (getReplyTemplate() != null) {

0 commit comments

Comments
 (0)