Program: 6263
Project: 6263
Buggy source:
/** 
 * Gets a Yarn delegation token and stores it in the given Credentials.
 * @return the same Credentials instance as the one given in parameter.
 */
public static Credentials obtainToken(YarnConfiguration configuration,Credentials credentials){
  if (!UserGroupInformation.isSecurityEnabled()) {
    return credentials;
  }
  try {
    YarnClient yarnClient=YarnClient.createYarnClient();
    yarnClient.init(configuration);
    yarnClient.start();
    try {
      Text renewer=new Text(UserGroupInformation.getCurrentUser().getShortUserName());
      org.apache.hadoop.yarn.api.records.Token rmDelegationToken=yarnClient.getRMDelegationToken(renewer);
      List<String> services=new ArrayList<>();
      if (HAUtil.isHAEnabled(configuration)) {
        YarnConfiguration yarnConf=new YarnConfiguration(configuration);
        for (        String rmId : HAUtil.getRMHAIds(configuration)) {
          yarnConf.set(YarnConfiguration.RM_HA_ID,rmId);
          InetSocketAddress address=yarnConf.getSocketAddr(YarnConfiguration.RM_ADDRESS,YarnConfiguration.DEFAULT_RM_ADDRESS,YarnConfiguration.DEFAULT_RM_PORT);
          services.add(SecurityUtil.buildTokenService(address).toString());
        }
      }
 else {
        services.add(SecurityUtil.buildTokenService(YarnUtils.getRMAddress(configuration)).toString());
      }
      Token<TokenIdentifier> token=ConverterUtils.convertFromYarn(rmDelegationToken,null);
      token.setService(new Text(Joiner.on(',').join(services)));
      credentials.addToken(new Text(token.getService()),token);
      LOG.info("String_Node_Str",token);
    }
  finally {
      yarnClient.stop();
    }
    return credentials;
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
/** 
 * Gets a Yarn delegation token and stores it in the given Credentials.
 * @return the same Credentials instance as the one given in parameter.
 */
public static Credentials obtainToken(YarnConfiguration configuration,Credentials credentials){
  if (!UserGroupInformation.isSecurityEnabled()) {
    return credentials;
  }
  try {
    YarnClient yarnClient=YarnClient.createYarnClient();
    yarnClient.init(configuration);
    yarnClient.start();
    try {
      Text renewer=new Text(UserGroupInformation.getCurrentUser().getShortUserName());
      org.apache.hadoop.yarn.api.records.Token rmDelegationToken=yarnClient.getRMDelegationToken(renewer);
      List<String> services=new ArrayList<>();
      if (HAUtil.isHAEnabled(configuration)) {
        YarnConfiguration yarnConf=new YarnConfiguration(configuration);
        for (        String rmId : HAUtil.getRMHAIds(configuration)) {
          yarnConf.set(YarnConfiguration.RM_HA_ID,rmId);
          InetSocketAddress address=yarnConf.getSocketAddr(YarnConfiguration.RM_ADDRESS,YarnConfiguration.DEFAULT_RM_ADDRESS,YarnConfiguration.DEFAULT_RM_PORT);
          services.add(SecurityUtil.buildTokenService(address).toString());
        }
      }
 else {
        services.add(SecurityUtil.buildTokenService(YarnUtils.getRMAddress(configuration)).toString());
      }
      Token<TokenIdentifier> token=ConverterUtils.convertFromYarn(rmDelegationToken,(InetSocketAddress)null);
      token.setService(new Text(Joiner.on(',').join(services)));
      credentials.addToken(new Text(token.getService()),token);
      LOG.info("String_Node_Str",token);
    }
  finally {
      yarnClient.stop();
    }
    return credentials;
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw Throwables.propagate(e);
  }
}