Skip to content

INT-3459: Log exceptions in case of failOver #2790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 7, 2019

Conversation

artembilan
Copy link
Member

JIRA: https://jira.spring.io/browse/INT-3459

When UnicastingDispatcher is configured with failOver (true by default),
it loses exceptions it caught with previous handler when the next one
processes message properly

  • Add INFO logging for exceptions which are caught before going to fail
    over to the next handler

catch (Exception ex) {
RuntimeException runtimeException =
IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
() -> "Dispatcher failed to deliver Message", ex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this line wrap? It was previously 112.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, my own preferences: I find it is much readable when variable initialization is multi-line. So, I start initialization block fully from a new line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

boolean isLast = !handlerIterator.hasNext();
if (!isLast && this.failover && this.logger.isInfoEnabled()) {
this.logger.info("An exception thrown from the '" + handler + "' for the '" + message + "'. " +
"Will be in a failover for the next subscriber.", ex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my language, but the two the should be removed.

this.logger.info("An exception was thrown by '" + handler + "' for while handling '" + message + "'. " +
							"Failing over to the next subscriber.", ex);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps only include full stack trace at DEBUG and ex.getMessage() at INFO?

@@ -137,18 +137,24 @@ private boolean doDispatch(Message<?> message) {
if (!handlerIterator.hasNext()) {
throw new MessageDispatchingException(message, "Dispatcher has no subscribers");
}
List<RuntimeException> exceptions = new ArrayList<RuntimeException>();
List<RuntimeException> exceptions = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create this array lazily because it's only used in error situations. 99.9999% not used.

JIRA: https://jira.spring.io/browse/INT-3459

When `UnicastingDispatcher` is configured with `failOver` (true by default),
it loses exceptions it caught with previous handler when the next one
processes message properly

* Add INFO logging for exceptions which are caught before going to fail
over to the next handler
}
else if (this.logger.isDebugEnabled()) {
this.logger.debug("An exception was thrown by '" + handler + "' while handling '" + message +
"'. Failing over to the next subscriber.", ex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug has to be detected first otherwise we'll always take the INFO branch.

* Add a note about this logging into the `channel.adoc`
@garyrussell garyrussell merged commit 3006e58 into spring-projects:master Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants