GH-3555: Change logger order for errorChannel (#3949)
* GH-3555: Change logger order for errorChannel Fixes https://github.com/spring-projects/spring-integration/issues/3555 The default global `errorChannel` has a `LoggingHandler` as a subscriber. It is subscribed without any `order` which may lose logging messages, when another subscriber with re-throw is present. * Set default `LoggingHandler` on the default `errorChannel` to `Ordered.LOWEST_PRECEDENCE - 100` to give a room for custom subscribers without an `order` and still get error logged * Add extra note in docs about an order for custom subcribers Co-authored-by: Gary Russell <grussell@vmware.com> Co-authored-by: Gary Russell <grussell@vmware.com>
This commit is contained in:
@@ -16,12 +16,17 @@
|
||||
|
||||
package org.springframework.integration.config.xml;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.handler.LoggingHandler;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -43,6 +48,15 @@ public class ErrorChannelAutoCreationTests {
|
||||
.isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(this.errorChannel, "dispatcher.ignoreFailures", Boolean.class))
|
||||
.isTrue();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<MessageHandler> handlers =
|
||||
TestUtils.getPropertyValue(this.errorChannel, "dispatcher.handlers", Set.class);
|
||||
|
||||
assertThat(handlers).first()
|
||||
.isInstanceOf(LoggingHandler.class)
|
||||
.extracting("order")
|
||||
.isEqualTo(Ordered.LOWEST_PRECEDENCE - 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user