Program: 166384
Project: 166384
Buggy source:
private void findBasicGroupProperties(LdapContext ldapContext) throws Throwable {
  int noOfGroups;
  Attribute groupNameAttr;
  String groupBase;
  String groupFilter;
  Attribute groupMemberAttr;
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  SearchControls groupSearchControls=new SearchControls();
  groupSearchControls.setSearchScope(config.getGroupSearchScope());
  try {
    int baseIndex=groupName.indexOf("String_Node_Str");
    groupBase=groupName.substring(baseIndex + 1);
    groupFilter=groupName.substring(0,baseIndex);
    groupSearchResultEnum=ldapContext.search(groupBase,groupFilter,groupSearchControls);
    noOfGroups=0;
    while (groupSearchResultEnum.hasMore()) {
      if (noOfGroups >= 1) {
        break;
      }
      final SearchResult groupEntry=groupSearchResultEnum.next();
      if (groupEntry == null) {
        continue;
      }
      Attributes groupAttributes=groupEntry.getAttributes();
      if (groupAttributes == null) {
        logFile.println("String_Node_Str" + groupEntry.getNameInNamespace());
        continue;
      }
      Attribute groupObjClassAttr=groupAttributes.get("String_Node_Str");
      if (groupObjClassAttr != null) {
        NamingEnumeration<?> groupObjClassEnum=groupObjClassAttr.getAll();
        while (groupObjClassEnum.hasMore()) {
          String groupObjClassStr=groupObjClassEnum.next().toString();
          for (int i=0; i < groupObjectClassValues.length; i++) {
            if (groupObjClassStr.equalsIgnoreCase(groupObjectClassValues[i])) {
              groupObjClassName=groupObjClassStr;
              break;
            }
          }
        }
      }
 else {
        logFile.println("String_Node_Str" + groupEntry.getNameInNamespace());
        continue;
      }
      if (groupNameAttrName == null || groupNameAttrName.isEmpty()) {
        for (int i=0; i < groupNameAttrValues.length; i++) {
          groupNameAttr=groupAttributes.get(groupNameAttrValues[i]);
          if (groupNameAttr != null) {
            groupNameAttrName=groupNameAttrValues[i];
            break;
          }
        }
      }
      for (int i=0; i < groupMemAttrValues.length; i++) {
        groupMemberAttr=groupAttributes.get(groupMemAttrValues[i]);
        if (groupMemberAttr != null) {
          groupMemberName=groupMemAttrValues[i];
          break;
        }
      }
      noOfGroups++;
    }
    installProps.println("String_Node_Str");
    installProps.println("String_Node_Str" + groupMemberName);
    installProps.println("String_Node_Str" + groupNameAttrName);
    installProps.println("String_Node_Str" + groupObjClassName);
    ambariProps.println("String_Node_Str");
    ambariProps.println("String_Node_Str" + groupMemberName);
    ambariProps.println("String_Node_Str" + groupNameAttrName);
    ambariProps.println("String_Node_Str" + groupObjClassName);
  }
  finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
  }
}

Fixed version (ground truth):
private void findBasicGroupProperties(LdapContext ldapContext) throws Throwable {
  int noOfGroups;
  Attribute groupNameAttr;
  String groupBase;
  String groupFilter;
  Attribute groupMemberAttr;
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  SearchControls groupSearchControls=new SearchControls();
  groupSearchControls.setSearchScope(config.getGroupSearchScope());
  try {
    if (groupName == null || groupName.isEmpty()) {
      groupSearchResultEnum=ldapContext.search(searchBase,null);
    }
 else {
      int baseIndex=groupName.indexOf("String_Node_Str");
      groupBase=groupName.substring(baseIndex + 1);
      groupFilter=groupName.substring(0,baseIndex);
      groupSearchResultEnum=ldapContext.search(groupBase,groupFilter,groupSearchControls);
    }
    noOfGroups=0;
    while (groupSearchResultEnum.hasMore()) {
      if (noOfGroups >= 1) {
        break;
      }
      final SearchResult groupEntry=groupSearchResultEnum.next();
      if (groupEntry == null) {
        continue;
      }
      Attributes groupAttributes=groupEntry.getAttributes();
      if (groupAttributes == null) {
        logFile.println("String_Node_Str" + groupEntry.getNameInNamespace());
        continue;
      }
      Attribute groupObjClassAttr=groupAttributes.get("String_Node_Str");
      if (groupObjClassAttr != null) {
        NamingEnumeration<?> groupObjClassEnum=groupObjClassAttr.getAll();
        while (groupObjClassEnum.hasMore()) {
          String groupObjClassStr=groupObjClassEnum.next().toString();
          for (int i=0; i < groupObjectClassValues.length; i++) {
            if (groupObjClassStr.equalsIgnoreCase(groupObjectClassValues[i])) {
              groupObjClassName=groupObjClassStr;
              break;
            }
          }
        }
      }
 else {
        logFile.println("String_Node_Str" + groupEntry.getNameInNamespace());
        continue;
      }
      if (groupNameAttrName == null || groupNameAttrName.isEmpty()) {
        for (int i=0; i < groupNameAttrValues.length; i++) {
          groupNameAttr=groupAttributes.get(groupNameAttrValues[i]);
          if (groupNameAttr != null) {
            groupNameAttrName=groupNameAttrValues[i];
            break;
          }
        }
      }
      for (int i=0; i < groupMemAttrValues.length; i++) {
        groupMemberAttr=groupAttributes.get(groupMemAttrValues[i]);
        if (groupMemberAttr != null) {
          groupMemberName=groupMemAttrValues[i];
          break;
        }
      }
      noOfGroups++;
    }
    installProps.println("String_Node_Str");
    installProps.println("String_Node_Str" + groupMemberName);
    installProps.println("String_Node_Str" + groupNameAttrName);
    installProps.println("String_Node_Str" + groupObjClassName);
    ambariProps.println("String_Node_Str");
    ambariProps.println("String_Node_Str" + groupMemberName);
    ambariProps.println("String_Node_Str" + groupNameAttrName);
    ambariProps.println("String_Node_Str" + groupObjClassName);
  }
  finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
  }
}