From a556c5944e3b5c59a7cda2e514293fb5c255a13a Mon Sep 17 00:00:00 2001 From: mikereiche Date: Fri, 13 Aug 2021 16:31:45 -0700 Subject: [PATCH] Log exceptions thrown from events. 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 4d2eaa423..8e487d95a 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 @@ public void maybeEmitEvent(CouchbaseMappingEvent event) { 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 @@ private boolean canPublishEvent() { 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 2a2c36cb7..845d9ca45 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 @@ public void maybeEmitEvent(CouchbaseMappingEvent event) { 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 @@ private boolean canPublishEvent() { 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"); }