/** This is a whitebox test, to verify a special case of the implementation. */ @Test public void statusFromCancelled_StatusUnknownShouldWork() { Context.CancellableContext cancellableContext = Context.current().withCancellation(); Exception e = Status.UNKNOWN.asException(); cancellableContext.cancel(e); assertTrue(cancellableContext.isCancelled()); Status status = statusFromCancelled(cancellableContext); assertNotNull(status); assertEquals(Status.Code.UNKNOWN, status.getCode()); assertSame(e, status.getCause()); }
@Override public void transportTerminated() { synchronized (lock) { if (activeTransport == transport) { log.warning("transportTerminated called without previous transportShutdown"); activeTransport = null; } // TODO(notcarl): replace this with something more meaningful transportShutdown(Status.UNKNOWN.withDescription("transport shutdown for unknown reason")); transports.remove(transport); if (shutdown && transports.isEmpty()) { if (terminated) { log.warning("transportTerminated called after already terminated"); } terminated = true; lock.notifyAll(); if (terminationRunnable != null) { terminationRunnable.run(); } } } }