Skip to content

Commit 59626fd

Browse files
author
hideki
committed
Updated Exception handling in postChangeNotifications() method
1 parent f5a1450 commit 59626fd

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/main/java/com/couchbase/lite/Database.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,16 +2226,26 @@ private boolean postChangeNotifications() {
22262226

22272227
final ChangeEvent changeEvent = new ChangeEvent(this, isExternal, outgoingChanges);
22282228
synchronized (changeListeners) {
2229-
for (ChangeListener changeListener : changeListeners)
2230-
changeListener.changed(changeEvent);
2229+
for (ChangeListener changeListener : changeListeners) {
2230+
if (changeListener != null) {
2231+
try {
2232+
changeListener.changed(changeEvent);
2233+
} catch (Exception ex) {
2234+
// Implementation of ChangeListener might throw RuntimeException,
2235+
// ignore it.
2236+
Log.e(TAG, "%s got exception posting change notification: %s",
2237+
ex, this, changeListener);
2238+
}
2239+
}
2240+
}
22312241
}
22322242
posted = true;
22332243
}
22342244
return posted;
22352245
} catch (Exception e) {
22362246
// In general, non of methods that are used in this method throws Exception.
2237-
// This catch block is just in case RuntimeExcepiton is thrown.
2238-
Log.e(TAG, "%s got exception posting change notifications", e, this);
2247+
// This catch block is just in case RuntimeException is thrown.
2248+
Log.e(TAG, "Unknown Exception: %s got exception posting change notifications", e, this);
22392249
return false;
22402250
} finally {
22412251
synchronized (lockPostingChangeNotifications) {

0 commit comments

Comments
 (0)