MCPcopy Index your code
hub / github.com/grpc/grpc-java / defaultContext

Method defaultContext

api/src/test/java/io/grpc/ContextTest.java:107–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105 }
106
107 @Test
108 public void defaultContext() throws Exception {
109 final SettableFuture<Context> contextOfNewThread = SettableFuture.create();
110 Context contextOfThisThread = Context.ROOT.withValue(PET, "dog");
111 Context toRestore = contextOfThisThread.attach();
112 new Thread(new Runnable() {
113 @Override
114 public void run() {
115 contextOfNewThread.set(Context.current());
116 }
117 }).start();
118 assertNotNull(contextOfNewThread.get(5, TimeUnit.SECONDS));
119 assertNotSame(contextOfThisThread, contextOfNewThread.get());
120 assertSame(contextOfThisThread, Context.current());
121 contextOfThisThread.detach(toRestore);
122 }
123
124 @Test
125 public void rootCanBeAttached() {

Callers

nothing calls this directly

Calls 7

attachMethod · 0.95
currentMethod · 0.95
detachMethod · 0.95
withValueMethod · 0.80
createMethod · 0.65
startMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected