From 561742e7dd30c84884f74ce6b60d1a6f8bbfe870 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 22 Mar 2021 18:30:02 +0100 Subject: [PATCH] GH-2118 Wrap publishing ApplicationEvent in try/catch . . . to ensure that any exceptions resulting from custom implementation of ApplicationLstener does not harm the application There will now be a WARN message and the stacj trace under DEBUG, but the application will continue to function. Resolves #2118 --- .../binder/AbstractMessageChannelBinder.java | 10 +++++++- .../ImplicitFunctionBindingTests.java | 23 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java index 462dd1668..d17294ff9 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/AbstractMessageChannelBinder.java @@ -918,7 +918,15 @@ public abstract class AbstractMessageChannelBinder echo() { + return x -> x; + } + + @Bean + public ApplicationListener bindingCreatedEventListener() { + return bindingCreatedEvent -> { + throw new RuntimeException("Test"); + }; + } + } + public static class Person { private String name; private int id;