OAuthCredentialsCache { private HeaderCacheElement syncRefresh(long timeout, TimeUnit timeUnit) { Span span = TRACER.spanBuilder("Bigtable.CredentialsRefresh").startSpan(); try (Scope scope = TRACER.withSpan(span)) { return asyncRefresh().get(timeout, timeUnit); } catch (InterruptedException e) { LOG.warn("Interrupted while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED.withDescription("Authentication was interrupted.").withCause(e); span.setStatus(StatusConverter.fromGrpcStatus(status)); Thread.currentThread().interrupt(); return new HeaderCacheElement(status); } catch (ExecutionException e) { LOG.warn("ExecutionException while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED .withDescription("ExecutionException during Authentication.") .withCause(e); span.setStatus(StatusConverter.fromGrpcStatus(status)); return new HeaderCacheElement(status); } catch (TimeoutException e) { LOG.warn("TimeoutException while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED .withDescription("TimeoutException during Authentication.") .withCause(e); span.setStatus(StatusConverter.fromGrpcStatus(status)); return new HeaderCacheElement(status); } catch (Exception e) { LOG.warn("Unexpected exception while trying to refresh google credentials.", e); Status status = Status.UNAUTHENTICATED .withDescription("Unexpected exception during Authentication.") .withCause(e); span.setStatus(StatusConverter.fromGrpcStatus(status)); return new HeaderCacheElement(status); } finally { span.end(); } } OAuthCredentialsCache(ExecutorService scheduler, OAuth2Credentials credentials);   }
@Test public void testSyncRefresh() throws Exception { initialize(HeaderCacheElement.TOKEN_STALENESS_MS + 1); Assert.assertEquals(CacheState.Good, underTest.getHeaderCache().getCacheState()); }