From f8b5ab205ced7ed5a95537623414ede26786d660 Mon Sep 17 00:00:00 2001 From: Michael Reiche <48999328+mikereiche@users.noreply.github.com> Date: Mon, 16 Aug 2021 13:15:22 -0700 Subject: [PATCH] Log exceptions thrown from events. (#1187) Closes #1075. --- .../data/couchbase/core/CouchbaseTemplateSupport.java | 8 ++------ .../couchbase/core/ReactiveCouchbaseTemplateSupport.java | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java index 4d2eaa42..8e487d95 100644 --- a/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java @@ -182,7 +182,7 @@ class CouchbaseTemplateSupport implements ApplicationContextAware, TemplateSuppo try { this.applicationContext.publishEvent(event); } catch (Exception e) { - e.printStackTrace(); + LOG.error("exception emitting event "+event, e); } } else { LOG.info("maybeEmitEvent called, but CouchbaseTemplate not initialized with applicationContext"); @@ -196,11 +196,7 @@ class CouchbaseTemplateSupport implements ApplicationContextAware, TemplateSuppo protected T maybeCallBeforeConvert(T object, String collection) { if (entityCallbacks != null) { - try { - return entityCallbacks.callback(BeforeConvertCallback.class, object, collection); - } catch (Exception e) { - e.printStackTrace(); - } + return entityCallbacks.callback(BeforeConvertCallback.class, object, collection); } else { LOG.info("maybeCallBeforeConvert called, but CouchbaseTemplate not initialized with applicationContext"); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java index 2a2c36cb..845d9ca4 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java @@ -189,7 +189,7 @@ class ReactiveCouchbaseTemplateSupport implements ApplicationContextAware, React try { this.applicationContext.publishEvent(event); } catch (Exception e) { - e.printStackTrace(); + LOG.error("exception emitting event "+event, e); } } else { LOG.info("maybeEmitEvent called, but ReactiveCouchbaseTemplate not initialized with applicationContext"); @@ -203,11 +203,7 @@ class ReactiveCouchbaseTemplateSupport implements ApplicationContextAware, React protected Mono maybeCallBeforeConvert(T object, String collection) { if (reactiveEntityCallbacks != null) { - try { - return reactiveEntityCallbacks.callback(ReactiveBeforeConvertCallback.class, object, collection); - } catch (Exception e) { - e.printStackTrace(); - } + return reactiveEntityCallbacks.callback(ReactiveBeforeConvertCallback.class, object, collection); } else { LOG.info("maybeCallBeforeConvert called, but ReactiveCouchbaseTemplate not initialized with applicationContext"); }