Program: 21100
Project: 21100
Buggy source:
/** 
 * Given   {@link CredentialOptions} that define how to look up credentials, do the following:<ol> <li> Look up the credentials <li> If there are credentials, create a gRPC interceptor that gets OAuth2 security tokens and add that token as a header on all calls. <br/>NOTE:  {@link RefreshingOAuth2CredentialsInterceptor} ensures that the token staysfresh. It does token lookups asynchronously so that the calls themselves take as little performance penalty as possible. <li> Cache the interceptor in step #2 if the  {@link CredentialOptions} uses<a href="https://developers.google.com/identity/protocols/application-default-credentials"> default application credentials </a> </ol>
 * @param credentialOptions Defines how credentials should be achieved
 * @param retryOptions
 * @return a HeaderInterceptor
 * @throws IOException
 * @throws GeneralSecurityException
 */
public synchronized HeaderInterceptor getCredentialsInterceptor(CredentialOptions credentialOptions,RetryOptions retryOptions) throws IOException, GeneralSecurityException {
  boolean isDefaultCredentials=credentialOptions.getCredentialType() == CredentialType.DefaultCredentials;
  if (isDefaultCredentials && defaultCredentialInterceptor != null) {
    return defaultCredentialInterceptor;
  }
  Credentials credentials=CredentialFactory.getCredentials(credentialOptions);
  if (credentials == null) {
    return null;
  }
  Preconditions.checkState(credentials instanceof OAuth2Credentials,String.format("String_Node_Str",credentials.getClass().getName()));
  RefreshingOAuth2CredentialsInterceptor oauth2Interceptor=new RefreshingOAuth2CredentialsInterceptor(executor,(OAuth2Credentials)credentials,retryOptions);
  oauth2Interceptor.asyncRefresh();
  if (isDefaultCredentials) {
    defaultCredentialInterceptor=oauth2Interceptor;
  }
  return oauth2Interceptor;
}

Fixed version (ground truth):
/** 
 * Given   {@link CredentialOptions} that define how to look up credentials, do the following:<ol> <li> Look up the credentials <li> If there are credentials, create a gRPC interceptor that gets OAuth2 security tokens and add that token as a header on all calls. <br>NOTE:  {@link RefreshingOAuth2CredentialsInterceptor} ensures that the token staysfresh. It does token lookups asynchronously so that the calls themselves take as little performance penalty as possible. <li> Cache the interceptor in step #2 if the  {@link CredentialOptions} uses<a href="https://developers.google.com/identity/protocols/application-default-credentials"> default application credentials </a> </ol>
 * @param credentialOptions Defines how credentials should be achieved
 * @param retryOptions
 * @return a HeaderInterceptor
 * @throws IOException
 * @throws GeneralSecurityException
 */
public synchronized HeaderInterceptor getCredentialsInterceptor(CredentialOptions credentialOptions,RetryOptions retryOptions) throws IOException, GeneralSecurityException {
  boolean isDefaultCredentials=credentialOptions.getCredentialType() == CredentialType.DefaultCredentials;
  if (isDefaultCredentials && defaultCredentialInterceptor != null) {
    return defaultCredentialInterceptor;
  }
  Credentials credentials=CredentialFactory.getCredentials(credentialOptions);
  if (credentials == null) {
    return null;
  }
  Preconditions.checkState(credentials instanceof OAuth2Credentials,String.format("String_Node_Str",credentials.getClass().getName()));
  RefreshingOAuth2CredentialsInterceptor oauth2Interceptor=new RefreshingOAuth2CredentialsInterceptor(executor,(OAuth2Credentials)credentials,retryOptions);
  oauth2Interceptor.asyncRefresh();
  if (isDefaultCredentials) {
    defaultCredentialInterceptor=oauth2Interceptor;
  }
  return oauth2Interceptor;
}