diff options
| -rw-r--r-- | api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java | 11 | ||||
| -rw-r--r-- | findbugs-exclude.xml | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java b/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java index 7ff7dd0a..a249d152 100644 --- a/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java +++ b/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java @@ -16,7 +16,6 @@ package io.opencensus.trace; -import com.google.common.base.Throwables; import io.grpc.Context; import io.opencensus.common.Scope; import io.opencensus.trace.unsafe.ContextUtils; @@ -121,7 +120,11 @@ final class CurrentSpanUtils { runnable.run(); } catch (Throwable t) { setErrorStatus(span, t); - Throwables.throwIfUnchecked(t); + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } else if (t instanceof Error) { + throw (Error) t; + } throw new RuntimeException("unexpected", t); } finally { Context.current().detach(origContext); @@ -154,7 +157,9 @@ final class CurrentSpanUtils { throw e; } catch (Throwable t) { setErrorStatus(span, t); - Throwables.throwIfUnchecked(t); + if (t instanceof Error) { + throw (Error) t; + } throw new RuntimeException("unexpected", t); } finally { Context.current().detach(origContext); diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml index 094bd2fa..87002bd0 100644 --- a/findbugs-exclude.xml +++ b/findbugs-exclude.xml @@ -28,6 +28,13 @@ <Class name="io.opencensus.internal.UtilsTest" /> <Method name="checkNotNull" /> </Match> + <Match> + <!-- Reason: It seems like FindBugs incorrectly assumes that all --> + <!-- Throwables are subclasses of Error or Exception. --> + <Bug pattern="BC_VACUOUS_INSTANCEOF"/> + <Class name="io.opencensus.trace.CurrentSpanUtils$CallableInSpan" /> + <Method name="call" /> + </Match> <!-- Suppress some FindBugs warnings related to performance or robustness --> <!-- in test classes, where those issues are less important. --> |
