Skip to content

Commit f8b5ab2

Browse files
authored
Log exceptions thrown from events. (#1187)
Closes #1075.
1 parent 5e92a99 commit f8b5ab2

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public void maybeEmitEvent(CouchbaseMappingEvent<?> event) {
182182
try {
183183
this.applicationContext.publishEvent(event);
184184
} catch (Exception e) {
185-
e.printStackTrace();
185+
LOG.error("exception emitting event "+event, e);
186186
}
187187
} else {
188188
LOG.info("maybeEmitEvent called, but CouchbaseTemplate not initialized with applicationContext");
@@ -196,11 +196,7 @@ private boolean canPublishEvent() {
196196

197197
protected <T> T maybeCallBeforeConvert(T object, String collection) {
198198
if (entityCallbacks != null) {
199-
try {
200-
return entityCallbacks.callback(BeforeConvertCallback.class, object, collection);
201-
} catch (Exception e) {
202-
e.printStackTrace();
203-
}
199+
return entityCallbacks.callback(BeforeConvertCallback.class, object, collection);
204200
} else {
205201
LOG.info("maybeCallBeforeConvert called, but CouchbaseTemplate not initialized with applicationContext");
206202
}

src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplateSupport.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void maybeEmitEvent(CouchbaseMappingEvent<?> event) {
189189
try {
190190
this.applicationContext.publishEvent(event);
191191
} catch (Exception e) {
192-
e.printStackTrace();
192+
LOG.error("exception emitting event "+event, e);
193193
}
194194
} else {
195195
LOG.info("maybeEmitEvent called, but ReactiveCouchbaseTemplate not initialized with applicationContext");
@@ -203,11 +203,7 @@ private boolean canPublishEvent() {
203203

204204
protected <T> Mono<T> maybeCallBeforeConvert(T object, String collection) {
205205
if (reactiveEntityCallbacks != null) {
206-
try {
207-
return reactiveEntityCallbacks.callback(ReactiveBeforeConvertCallback.class, object, collection);
208-
} catch (Exception e) {
209-
e.printStackTrace();
210-
}
206+
return reactiveEntityCallbacks.callback(ReactiveBeforeConvertCallback.class, object, collection);
211207
} else {
212208
LOG.info("maybeCallBeforeConvert called, but ReactiveCouchbaseTemplate not initialized with applicationContext");
213209
}

0 commit comments

Comments
 (0)