Skip to content

Commit 13395e8

Browse files
author
Hideki Itakura
committed
Batcher class uses Exception.printStackTrace() that has confused users. By this commit, update logging message
1 parent 0292e05 commit 13395e8

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/main/java/com/couchbase/lite/support/Batcher.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Iterator;
88
import java.util.List;
99
import java.util.concurrent.BlockingQueue;
10+
import java.util.concurrent.CancellationException;
1011
import java.util.concurrent.ExecutionException;
1112
import java.util.concurrent.Future;
1213
import java.util.concurrent.LinkedBlockingQueue;
@@ -107,28 +108,25 @@ public void queueObjects(List<T> objects) {
107108
}
108109

109110
public void waitForPendingFutures() {
110-
111111
Log.d(Log.TAG_BATCHER, "%s: waitForPendingFutures", this);
112-
113112
try {
114-
115113
while (!pendingFutures.isEmpty()) {
116114
Future future = pendingFutures.take();
117115
try {
118116
Log.d(Log.TAG_BATCHER, "calling future.get() on %s", future);
119117
future.get();
120118
Log.d(Log.TAG_BATCHER, "done calling future.get() on %s", future);
121-
} catch (InterruptedException e) {
122-
e.printStackTrace();
119+
} catch (CancellationException e) {
120+
Log.i(Log.TAG_BATCHER, "Task was canceled: " + e.getMessage());
123121
} catch (ExecutionException e) {
124-
e.printStackTrace();
122+
Log.e(Log.TAG_BATCHER, "ERROR: Task aborted: " + e.getMessage());
123+
} catch (InterruptedException e) {
124+
Log.w(Log.TAG_BATCHER, e.getMessage());
125125
}
126126
}
127-
128127
} catch (Exception e) {
129128
Log.e(Log.TAG_BATCHER, "Exception waiting for pending futures: %s", e);
130129
}
131-
132130
Log.d(Log.TAG_BATCHER, "%s: /waitForPendingFutures", this);
133131
}
134132

0 commit comments

Comments
 (0)