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 execption while trying to refresh google credentials." , e ) ; Status status = Status . UNAUTHENTICATED . withDescription ( "Unexpected execption during Authentication." ) . withCause ( e ) ; span . setStatus ( StatusConverter . fromGrpcStatus ( status ) ) ; return new HeaderCacheElement ( status ) ; } finally { span . end ( ) ; } }
Refresh the credentials and block . Will return an error if the credentials haven t been refreshed . This method should not be called while holding the refresh lock