From 6c2dbc4708c2db6ecc3ac4a094d70fe3fc83915c 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 77dfd9d06..a93715271 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 @@ -917,7 +917,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;