diff options
author | sebright <sebright@google.com> | 2018-08-01 17:54:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 17:54:30 -0700 |
commit | daa5d097e18211ad95a0e5bc63697e615db91902 (patch) | |
tree | 6022a2f76f3d883569eff2ca007fdcedd32cc879 /api/src/main/java/io | |
parent | 87f199dba62baf5003c039d000c3a576859ebb93 (diff) | |
download | opencensus-java-daa5d097e18211ad95a0e5bc63697e615db91902.tar.gz |
Add Checker Framework stub file for gRPC Context.Key. (#1357)
The stub file adds Nullable annotations to indicate that Context.Key.get can
return null when the key has no default or the key has a nullable value type.
Diffstat (limited to 'api/src/main/java/io')
-rw-r--r-- | api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java | 2 | ||||
-rw-r--r-- | api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java b/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java index 21511142..aa2f055a 100644 --- a/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java +++ b/api/src/main/java/io/opencensus/trace/CurrentSpanUtils.java @@ -20,6 +20,7 @@ import io.grpc.Context; import io.opencensus.common.Scope; import io.opencensus.trace.unsafe.ContextUtils; import java.util.concurrent.Callable; +import javax.annotation.Nullable; /** Util methods/functionality to interact with the {@link Span} in the {@link io.grpc.Context}. */ final class CurrentSpanUtils { @@ -31,6 +32,7 @@ final class CurrentSpanUtils { * * @return The {@code Span} from the current context. */ + @Nullable static Span getCurrentSpan() { return ContextUtils.CONTEXT_SPAN_KEY.get(); } diff --git a/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java b/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java index f7905c25..3f4b9889 100644 --- a/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java +++ b/api/src/main/java/io/opencensus/trace/unsafe/ContextUtils.java @@ -19,6 +19,10 @@ package io.opencensus.trace.unsafe; import io.grpc.Context; import io.opencensus.trace.Span; +/*>>> +import org.checkerframework.checker.nullness.qual.Nullable; +*/ + /** * Util methods/functionality to interact with the {@link io.grpc.Context}. * @@ -36,5 +40,6 @@ public final class ContextUtils { * * @since 0.5 */ - public static final Context.Key<Span> CONTEXT_SPAN_KEY = Context.key("opencensus-trace-span-key"); + public static final Context.Key</*@Nullable*/ Span> CONTEXT_SPAN_KEY = + Context.key("opencensus-trace-span-key"); } |