aboutsummaryrefslogtreecommitdiff
path: root/context
diff options
context:
space:
mode:
authorzpencer <spencerfang@google.com>2017-05-17 17:12:45 -0700
committerGitHub <noreply@github.com>2017-05-17 17:12:45 -0700
commit347eb09d925d7732b9469e34fa65df4de921329f (patch)
treebd2521deaede3a2f0271c3909000846e6345bd2a /context
parent66ebcb1b00dfb32a2e38ee4586268cb402f3f43a (diff)
downloadgrpc-grpc-java-347eb09d925d7732b9469e34fa65df4de921329f.tar.gz
all: Minor updates to expand javadocs (#2991)
all: Minor updates to expand javadocs
Diffstat (limited to 'context')
-rw-r--r--context/src/main/java/io/grpc/Context.java9
-rw-r--r--context/src/test/java/io/grpc/ContextTest.java3
2 files changed, 12 insertions, 0 deletions
diff --git a/context/src/main/java/io/grpc/Context.java b/context/src/main/java/io/grpc/Context.java
index 3c12dba64..605fe6262 100644
--- a/context/src/main/java/io/grpc/Context.java
+++ b/context/src/main/java/io/grpc/Context.java
@@ -742,7 +742,16 @@ public class Context {
uncancellableSurrogate.detach(toAttach);
}
+ /**
+ * Returns true if the Context is the current context.
+ *
+ * @deprecated This method violates some GRPC class encapsulation and should not be used.
+ * If you must know whether a Context is the current context, check whether it is the same
+ * object returned by {@link Context#current()}.
+ */
+ //TODO(spencerfang): The superclass's method is package-private, so this should really match.
@Override
+ @Deprecated
public boolean isCurrent() {
return uncancellableSurrogate.isCurrent();
}
diff --git a/context/src/test/java/io/grpc/ContextTest.java b/context/src/test/java/io/grpc/ContextTest.java
index cd1c40593..a3cf70eb2 100644
--- a/context/src/test/java/io/grpc/ContextTest.java
+++ b/context/src/test/java/io/grpc/ContextTest.java
@@ -392,6 +392,9 @@ public class ContextTest {
assertSame(t, child.cancellationCause());
}
+ // Context#isCurrent() and Context.CancellableContext#isCurrent() are intended
+ // to be visible only for testing. The deprecation is meant for users.
+ @SuppressWarnings("deprecation")
@Test
public void cancellableContextIsAttached() {
Context.CancellableContext base = Context.current().withValue(FOOD, "fish").withCancellation();