Program: 14061
Project: 14061
Buggy source:
/** 
 * Check the output for the given resource string, but only if the tid matches
 * @param output
 * @param resource
 * @return
 */
private static boolean hasResource(@Nonnull String output,int tid,@Nonnull String resource,String user,boolean checkInitiators){
  Matcher targetMatcher=null;
  Matcher resourceMatcher=null;
  Matcher userHeaderMatcher=null;
  Matcher userMatcher=null;
  Matcher initiatorsHeaderMatcher=null;
  Matcher initiatorsMatcher=null;
  String target=null;
  boolean resourceFound=false;
  boolean userHeaderFound=false;
  boolean userFound=false;
  boolean initiatorsHeaderFound=false;
  boolean initiatorsFound=false;
  for (  String line : LINE_SPLITTER.split(output)) {
    targetMatcher=TARGET_PATTERN.matcher(line);
    if (targetMatcher.matches()) {
      target=targetMatcher.group(1);
      if (Integer.parseInt(target) != tid) {
        target=null;
      }
    }
    if (target == null) {
      continue;
    }
    if (!resourceFound) {
      resourceMatcher=RESOURCE_PATTERN.matcher(line);
      if (resourceMatcher.matches() && resourceMatcher.group(1).equals(resource)) {
        resourceFound=true;
      }
      continue;
    }
    if (user != null && !userFound) {
      if (!userHeaderFound) {
        userHeaderMatcher=USER_HEADER_PATTERN.matcher(line);
        if (userHeaderMatcher.matches()) {
          userHeaderFound=true;
          continue;
        }
      }
 else {
        userMatcher=TRIMMED_ANYTHING_PATTERN.matcher(line);
        if (userMatcher.group(1).equals(user)) {
          userFound=true;
        }
 else {
          return false;
        }
      }
    }
    if (checkInitiators && !initiatorsFound) {
      if (!initiatorsHeaderFound) {
        initiatorsHeaderMatcher=INITIATORS_HEADER_PATTERN.matcher(line);
        if (initiatorsHeaderMatcher.matches()) {
          initiatorsHeaderFound=true;
          continue;
        }
      }
 else {
        initiatorsMatcher=TRIMMED_ANYTHING_PATTERN.matcher(line);
        if (initiatorsMatcher.group(1).equals(INITIATOR_ACCESS_LIST)) {
          initiatorsFound=true;
        }
 else {
          return false;
        }
      }
    }
    if ((user == null || userFound) && (!checkInitiators || initiatorsFound)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Check the output for the given resource string, but only if the tid matches
 * @param output
 * @param resource
 * @return
 */
private static boolean hasResource(@Nonnull String output,int tid,@Nonnull String resource,String user,boolean checkInitiators){
  Matcher targetMatcher=null;
  Matcher resourceMatcher=null;
  Matcher userHeaderMatcher=null;
  Matcher userMatcher=null;
  Matcher initiatorsHeaderMatcher=null;
  Matcher initiatorsMatcher=null;
  String target=null;
  boolean resourceFound=false;
  boolean userHeaderFound=false;
  boolean userFound=false;
  boolean initiatorsHeaderFound=false;
  boolean initiatorsFound=false;
  for (  String line : LINE_SPLITTER.split(output)) {
    targetMatcher=TARGET_PATTERN.matcher(line);
    if (targetMatcher.matches()) {
      if (target == null) {
        if (Integer.parseInt(targetMatcher.group(1)) == tid) {
          target=targetMatcher.group(1);
        }
      }
 else {
        break;
      }
      continue;
    }
    if (target == null) {
      continue;
    }
    if (!resourceFound) {
      resourceMatcher=RESOURCE_PATTERN.matcher(line);
      if (resourceMatcher.matches() && resourceMatcher.group(1).equals(resource)) {
        resourceFound=true;
      }
      continue;
    }
    if (user != null && !userFound) {
      if (!userHeaderFound) {
        userHeaderMatcher=USER_HEADER_PATTERN.matcher(line);
        if (userHeaderMatcher.matches()) {
          userHeaderFound=true;
          continue;
        }
      }
 else {
        userMatcher=TRIMMED_ANYTHING_PATTERN.matcher(line);
        if (userMatcher.matches()) {
          if (userMatcher.group(1).equals(user)) {
            userFound=true;
          }
 else {
            return false;
          }
        }
 else {
          return false;
        }
      }
    }
    if (checkInitiators && !initiatorsFound) {
      if (!initiatorsHeaderFound) {
        initiatorsHeaderMatcher=INITIATORS_HEADER_PATTERN.matcher(line);
        if (initiatorsHeaderMatcher.matches()) {
          initiatorsHeaderFound=true;
          continue;
        }
      }
 else {
        initiatorsMatcher=TRIMMED_ANYTHING_PATTERN.matcher(line);
        if (initiatorsMatcher.matches()) {
          if (initiatorsMatcher.group(1).equals(INITIATOR_ACCESS_LIST)) {
            initiatorsFound=true;
          }
 else {
            return false;
          }
        }
 else {
          return false;
        }
      }
    }
    if ((user == null || userFound) && (!checkInitiators || initiatorsFound)) {
      return true;
    }
  }
  return false;
}