aboutsummaryrefslogtreecommitdiff
path: root/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java')
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
index 4ef7ed36c..e6284e1c7 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* A list of listeners for implementing a concurrency friendly observable object.
@@ -58,7 +57,7 @@ import java.util.logging.Logger;
@ElementTypesAreNonnullByDefault
final class ListenerCallQueue<L> {
// TODO(cpovirk): consider using the logger associated with listener.getClass().
- private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ListenerCallQueue.class);
// TODO(chrisn): promote AppendOnlyCollection for use here.
private final List<PerListenerQueue<L>> listeners =
@@ -159,6 +158,7 @@ final class ListenerCallQueue<L> {
* Dispatches all listeners {@linkplain #enqueue enqueued} prior to this call, serially and in
* order.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
void dispatch() {
boolean scheduleEventRunner = false;
synchronized (this) {
@@ -170,22 +170,25 @@ final class ListenerCallQueue<L> {
if (scheduleEventRunner) {
try {
executor.execute(this);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// reset state in case of an error so that later dispatch calls will actually do something
synchronized (this) {
isThreadScheduled = false;
}
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while running callbacks for " + listener + " on " + executor,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while running callbacks for " + listener + " on " + executor,
+ e);
throw e;
}
}
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void run() {
boolean stillRunning = true;
try {
@@ -206,12 +209,14 @@ final class ListenerCallQueue<L> {
// Always run while _not_ holding the lock, to avoid deadlocks.
try {
nextToRun.call(listener);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while executing callback: " + listener + " " + nextLabel,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while executing callback: " + listener + " " + nextLabel,
+ e);
}
}
} finally {