Program: 166385
Project: 166385
Buggy source:
private void findBasicUserProperties(LdapContext ldapContext,boolean isOutputNeeded) throws Throwable {
  String bindDn=config.getLdapBindDn();
  String userSFilter=config.getUserSearchFilter();
  String userSBase=config.getUserSearchBase();
  Attribute userNameAttr=null;
  Attribute groupMemberAttr;
  SearchControls userSearchControls=new SearchControls();
  userSearchControls.setSearchScope(config.getUserSearchScope());
  userSearchControls.setReturningAttributes(new java.lang.String[]{"String_Node_Str","String_Node_Str"});
  int noOfUsers=0;
  NamingEnumeration<SearchResult> userSearchResultEnum=null;
  try {
    if (userSBase == null || userSBase.isEmpty()) {
      if (bindDn.contains("String_Node_Str")) {
        userSBase=bindDn.substring(bindDn.indexOf("String_Node_Str") + 1);
        userSBase="String_Node_Str".concat(userSBase);
        userSBase=userSBase.replaceAll("String_Node_Str","String_Node_Str");
      }
 else {
        userSBase=bindDn.substring(bindDn.indexOf("String_Node_Str") + 1);
      }
    }
    if (userSFilter == null || userSFilter.isEmpty()) {
      if (bindDn.contains("String_Node_Str")) {
        userSFilter="String_Node_Str" + bindDn;
      }
 else {
        int cnEndIndex=bindDn.indexOf("String_Node_Str");
        userSFilter=bindDn.substring(0,cnEndIndex);
      }
    }
    try {
      userSearchResultEnum=ldapContext.search(userSBase,userSFilter,userSearchControls);
      while (userSearchResultEnum.hasMore()) {
        if (noOfUsers >= 1) {
          break;
        }
        final SearchResult userEntry=userSearchResultEnum.next();
        if (userEntry == null) {
          logFile.println("String_Node_Str");
          continue;
        }
        Attributes attributes=userEntry.getAttributes();
        if (attributes == null) {
          logFile.println("String_Node_Str" + userEntry.getNameInNamespace());
          continue;
        }
        if (userNameAttribute == null || userNameAttribute.isEmpty()) {
          for (int i=0; i < userNameAttrValues.length; i++) {
            userNameAttr=attributes.get(userNameAttrValues[i]);
            if (userNameAttr != null) {
              userNameAttribute=userNameAttrValues[i];
              break;
            }
          }
          if (userNameAttr == null) {
            logFile.print("String_Node_Str");
            for (int i=0; i < userNameAttrValues.length; i++) {
              logFile.print(userNameAttrValues[i] + "String_Node_Str");
            }
            logFile.println("String_Node_Str" + userEntry.getNameInNamespace());
            continue;
          }
        }
 else {
          userNameAttr=attributes.get(userNameAttribute);
          if (userNameAttr == null) {
            logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
            continue;
          }
        }
        String userName=(String)userNameAttr.get();
        if (userName == null || userName.trim().isEmpty()) {
          logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
          continue;
        }
        userName=userName.toLowerCase();
        Attribute userObjClassAttr=attributes.get("String_Node_Str");
        NamingEnumeration<?> userObjClassEnum=userObjClassAttr.getAll();
        String userObjClass=null;
        while (userObjClassEnum.hasMore()) {
          userObjClass=userObjClassEnum.next().toString();
          if (userObjClassName == null || userObjClassName.isEmpty()) {
            if (userObjClass != null) {
              for (int i=0; i < userObjClassValues.length; i++) {
                if (userObjClass.equalsIgnoreCase(userObjClassValues[i])) {
                  userObjClassName=userObjClass;
                  break;
                }
              }
            }
 else {
              logFile.println("String_Node_Str" + userName);
            }
          }
        }
        if (userObjClassName == null || userObjClassName.isEmpty()) {
          userObjClassName=userObjClass;
        }
        for (int i=0; i < userGroupMemAttrValues.length; i++) {
          groupMemberAttr=attributes.get(userGroupMemAttrValues[i]);
          if (groupMemberAttr != null) {
            userGroupMemberName=userGroupMemAttrValues[i];
            groupName=groupMemberAttr.get(1).toString();
            break;
          }
        }
        noOfUsers++;
      }
    }
 catch (    NamingException ne) {
      String msg="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
      if ((config.getUserSearchBase() != null && !config.getUserSearchBase().isEmpty()) || (config.getUserSearchFilter() != null && !config.getUserSearchFilter().isEmpty())) {
        throw new Exception(msg + "String_Node_Str");
      }
 else {
        throw new Exception(msg + ne);
      }
    }
    if (isOutputNeeded) {
      installProps.println("String_Node_Str");
      installProps.println("String_Node_Str" + userNameAttribute);
      installProps.println("String_Node_Str" + userObjClassName);
      installProps.println("String_Node_Str" + userGroupMemberName);
      ambariProps.println("String_Node_Str");
      ambariProps.println("String_Node_Str" + userNameAttribute);
      ambariProps.println("String_Node_Str" + userObjClassName);
      ambariProps.println("String_Node_Str" + userGroupMemberName);
    }
  }
  finally {
    try {
      if (userSearchResultEnum != null) {
        userSearchResultEnum.close();
      }
    }
 catch (    NamingException ne) {
      throw new Exception("String_Node_Str" + ne);
    }
  }
}

Fixed version (ground truth):
private void findBasicUserProperties(LdapContext ldapContext,boolean isOutputNeeded) throws Throwable {
  String bindDn=config.getLdapBindDn();
  String userSFilter=config.getUserSearchFilter();
  String userSBase=config.getUserSearchBase();
  Attribute userNameAttr=null;
  Attribute groupMemberAttr;
  SearchControls userSearchControls=new SearchControls();
  userSearchControls.setSearchScope(config.getUserSearchScope());
  userSearchControls.setReturningAttributes(new java.lang.String[]{"String_Node_Str","String_Node_Str"});
  int noOfUsers=0;
  NamingEnumeration<SearchResult> userSearchResultEnum=null;
  try {
    if (userSBase == null || userSBase.isEmpty()) {
      if (bindDn.contains("String_Node_Str")) {
        userSBase=bindDn.substring(bindDn.indexOf("String_Node_Str") + 1);
        userSBase="String_Node_Str".concat(userSBase);
        userSBase=userSBase.replaceAll("String_Node_Str","String_Node_Str");
      }
 else {
        userSBase=bindDn.substring(bindDn.indexOf("String_Node_Str") + 1);
      }
    }
    if (userSFilter == null || userSFilter.isEmpty()) {
      if (bindDn.contains("String_Node_Str")) {
        userSFilter="String_Node_Str" + bindDn;
      }
 else {
        int cnEndIndex=bindDn.indexOf("String_Node_Str");
        userSFilter=bindDn.substring(0,cnEndIndex);
      }
    }
    try {
      userSearchResultEnum=ldapContext.search(userSBase,userSFilter,userSearchControls);
      while (userSearchResultEnum.hasMore()) {
        if (noOfUsers >= 1) {
          break;
        }
        final SearchResult userEntry=userSearchResultEnum.next();
        if (userEntry == null) {
          logFile.println("String_Node_Str");
          continue;
        }
        Attributes attributes=userEntry.getAttributes();
        if (attributes == null) {
          logFile.println("String_Node_Str" + userEntry.getNameInNamespace());
          continue;
        }
        if (userNameAttribute == null || userNameAttribute.isEmpty()) {
          for (int i=0; i < userNameAttrValues.length; i++) {
            userNameAttr=attributes.get(userNameAttrValues[i]);
            if (userNameAttr != null) {
              userNameAttribute=userNameAttrValues[i];
              break;
            }
          }
          if (userNameAttr == null) {
            logFile.print("String_Node_Str");
            for (int i=0; i < userNameAttrValues.length; i++) {
              logFile.print(userNameAttrValues[i] + "String_Node_Str");
            }
            logFile.println("String_Node_Str" + userEntry.getNameInNamespace());
            continue;
          }
        }
 else {
          userNameAttr=attributes.get(userNameAttribute);
          if (userNameAttr == null) {
            logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
            continue;
          }
        }
        String userName=(String)userNameAttr.get();
        if (userName == null || userName.trim().isEmpty()) {
          logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
          continue;
        }
        userName=userName.toLowerCase();
        Attribute userObjClassAttr=attributes.get("String_Node_Str");
        NamingEnumeration<?> userObjClassEnum=userObjClassAttr.getAll();
        String userObjClass=null;
        while (userObjClassEnum.hasMore()) {
          userObjClass=userObjClassEnum.next().toString();
          if (userObjClassName == null || userObjClassName.isEmpty()) {
            if (userObjClass != null) {
              for (int i=0; i < userObjClassValues.length; i++) {
                if (userObjClass.equalsIgnoreCase(userObjClassValues[i])) {
                  userObjClassName=userObjClass;
                  break;
                }
              }
            }
 else {
              logFile.println("String_Node_Str" + userName);
            }
          }
        }
        if (userObjClassName == null || userObjClassName.isEmpty()) {
          userObjClassName=userObjClass;
        }
        for (int i=0; i < userGroupMemAttrValues.length; i++) {
          groupMemberAttr=attributes.get(userGroupMemAttrValues[i]);
          if (groupMemberAttr != null) {
            userGroupMemberName=userGroupMemAttrValues[i];
            groupName=groupMemberAttr.get(0).toString();
            break;
          }
        }
        noOfUsers++;
      }
    }
 catch (    NamingException ne) {
      String msg="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
      if ((config.getUserSearchBase() != null && !config.getUserSearchBase().isEmpty()) || (config.getUserSearchFilter() != null && !config.getUserSearchFilter().isEmpty())) {
        throw new Exception(msg + "String_Node_Str");
      }
 else {
        throw new Exception(msg + ne);
      }
    }
    if (isOutputNeeded) {
      installProps.println("String_Node_Str");
      installProps.println("String_Node_Str" + userNameAttribute);
      installProps.println("String_Node_Str" + userObjClassName);
      installProps.println("String_Node_Str" + userGroupMemberName);
      ambariProps.println("String_Node_Str");
      ambariProps.println("String_Node_Str" + userNameAttribute);
      ambariProps.println("String_Node_Str" + userObjClassName);
      ambariProps.println("String_Node_Str" + userGroupMemberName);
    }
  }
  finally {
    try {
      if (userSearchResultEnum != null) {
        userSearchResultEnum.close();
      }
    }
 catch (    NamingException ne) {
      throw new Exception("String_Node_Str" + ne);
    }
  }
}