Program: 166383
Project: 166383
Buggy source:
public void getAllUsers(LdapContext ldapContext) throws Throwable {
  int noOfUsers=0;
  Attribute userNameAttr=null;
  String groupName=null;
  Attribute groupMemberAttr;
  NamingEnumeration<SearchResult> userSearchResultEnum=null;
  SearchControls userSearchControls=new SearchControls();
  userSearchControls.setSearchScope(config.getUserSearchScope());
  Set<String> userSearchAttributes=new HashSet<>();
  if (userNameAttribute != null) {
    userSearchAttributes.add(userNameAttribute);
  }
  if (userGroupMemberName != null) {
    userSearchAttributes.add(userGroupMemberName);
  }
  if (userSearchAttributes.size() > 0) {
    userSearchControls.setReturningAttributes(userSearchAttributes.toArray(new String[userSearchAttributes.size()]));
  }
 else {
    userSearchControls.setReturningAttributes(new java.lang.String[]{"String_Node_Str","String_Node_Str"});
  }
  String extendedUserSearchFilter="String_Node_Str" + userObjClassName + "String_Node_Str";
  if (userSearchFilter != null && !userSearchFilter.trim().isEmpty()) {
    String customFilter=userSearchFilter.trim();
    if (!customFilter.startsWith("String_Node_Str")) {
      customFilter="String_Node_Str" + customFilter + "String_Node_Str";
    }
    extendedUserSearchFilter="String_Node_Str" + extendedUserSearchFilter + customFilter+ "String_Node_Str";
  }
  byte[] cookie=null;
  logFile.println();
  logFile.println("String_Node_Str");
  try {
    do {
      userSearchResultEnum=ldapContext.search(userSearchBase,extendedUserSearchFilter,userSearchControls);
      while (userSearchResultEnum.hasMore()) {
        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=userNameAttr.get().toString();
        if (userName == null || userName.trim().isEmpty()) {
          logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
          continue;
        }
        userName=userName.toLowerCase();
        Set<String> groups=new HashSet<>();
        groupMemberAttr=attributes.get(userGroupMemberName);
        if (groupMemberAttr != null) {
          NamingEnumeration<?> groupEnum=groupMemberAttr.getAll();
          while (groupEnum.hasMore()) {
            String groupRes=groupEnum.next().toString();
            groups.add(groupRes);
            if (groupName == null || groupName.isEmpty()) {
              groupName=groupRes;
            }
          }
        }
        if (noOfUsers < 20) {
          logFile.println("String_Node_Str" + userName + "String_Node_Str"+ groups);
        }
        noOfUsers++;
      }
      Control[] controls=ldapContext.getResponseControls();
      if (controls != null) {
        for (int i=0; i < controls.length; i++) {
          if (controls[i] instanceof PagedResultsResponseControl) {
            PagedResultsResponseControl prrc=(PagedResultsResponseControl)controls[i];
            cookie=prrc.getCookie();
          }
        }
      }
 else {
        logFile.println("String_Node_Str");
      }
      if (config.isPagedResultsEnabled()) {
        ldapContext.setRequestControls(new Control[]{new PagedResultsControl(config.getPagedResultsSize(),cookie,Control.CRITICAL)});
      }
    }
 while (cookie != null);
    logFile.println("String_Node_Str" + noOfUsers);
  }
 catch (  NamingException ne) {
    String msg="String_Node_Str";
    if ((config.getUserNameAttribute() != null && !config.getUserNameAttribute().isEmpty()) || (config.getUserObjectClass() != null && !config.getUserObjectClass().isEmpty()) || (config.getGroupNameAttribute() != null && !config.getGroupNameAttribute().isEmpty())|| (config.getUserSearchBase() != null && !config.getUserSearchBase().isEmpty())|| (config.getUserSearchFilter() != null && !config.getUserSearchFilter().isEmpty())) {
      throw new Exception("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    }
 else {
      throw new Exception(msg + ne);
    }
  }
 finally {
    if (userSearchResultEnum != null) {
      userSearchResultEnum.close();
    }
  }
}

Fixed version (ground truth):
public void getAllUsers(LdapContext ldapContext) throws Throwable {
  int noOfUsers=0;
  Attribute userNameAttr=null;
  Attribute groupMemberAttr;
  NamingEnumeration<SearchResult> userSearchResultEnum=null;
  SearchControls userSearchControls=new SearchControls();
  userSearchControls.setSearchScope(config.getUserSearchScope());
  Set<String> userSearchAttributes=new HashSet<>();
  if (userNameAttribute != null) {
    userSearchAttributes.add(userNameAttribute);
  }
  if (userGroupMemberName != null) {
    userSearchAttributes.add(userGroupMemberName);
  }
  if (userSearchAttributes.size() > 0) {
    userSearchControls.setReturningAttributes(userSearchAttributes.toArray(new String[userSearchAttributes.size()]));
  }
 else {
    userSearchControls.setReturningAttributes(new java.lang.String[]{"String_Node_Str","String_Node_Str"});
  }
  String extendedUserSearchFilter="String_Node_Str" + userObjClassName + "String_Node_Str";
  if (userSearchFilter != null && !userSearchFilter.trim().isEmpty()) {
    String customFilter=userSearchFilter.trim();
    if (!customFilter.startsWith("String_Node_Str")) {
      customFilter="String_Node_Str" + customFilter + "String_Node_Str";
    }
    extendedUserSearchFilter="String_Node_Str" + extendedUserSearchFilter + customFilter+ "String_Node_Str";
  }
  byte[] cookie=null;
  logFile.println();
  logFile.println("String_Node_Str");
  try {
    do {
      userSearchResultEnum=ldapContext.search(userSearchBase,extendedUserSearchFilter,userSearchControls);
      while (userSearchResultEnum.hasMore()) {
        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=userNameAttr.get().toString();
        if (userName == null || userName.trim().isEmpty()) {
          logFile.println("String_Node_Str" + userNameAttribute + "String_Node_Str"+ userEntry.getNameInNamespace());
          continue;
        }
        userName=userName.toLowerCase();
        Set<String> groups=new HashSet<>();
        groupMemberAttr=attributes.get(userGroupMemberName);
        if (groupMemberAttr != null) {
          NamingEnumeration<?> groupEnum=groupMemberAttr.getAll();
          while (groupEnum.hasMore()) {
            String groupRes=groupEnum.next().toString();
            groups.add(groupRes);
            if (groupName == null || groupName.isEmpty()) {
              groupName=groupRes;
            }
          }
        }
        if (noOfUsers < 20) {
          logFile.println("String_Node_Str" + userName + "String_Node_Str"+ groups);
        }
        noOfUsers++;
      }
      Control[] controls=ldapContext.getResponseControls();
      if (controls != null) {
        for (int i=0; i < controls.length; i++) {
          if (controls[i] instanceof PagedResultsResponseControl) {
            PagedResultsResponseControl prrc=(PagedResultsResponseControl)controls[i];
            cookie=prrc.getCookie();
          }
        }
      }
 else {
        logFile.println("String_Node_Str");
      }
      if (config.isPagedResultsEnabled()) {
        ldapContext.setRequestControls(new Control[]{new PagedResultsControl(config.getPagedResultsSize(),cookie,Control.CRITICAL)});
      }
    }
 while (cookie != null);
    logFile.println("String_Node_Str" + noOfUsers);
  }
 catch (  NamingException ne) {
    String msg="String_Node_Str";
    if ((config.getUserNameAttribute() != null && !config.getUserNameAttribute().isEmpty()) || (config.getUserObjectClass() != null && !config.getUserObjectClass().isEmpty()) || (config.getGroupNameAttribute() != null && !config.getGroupNameAttribute().isEmpty())|| (config.getUserSearchBase() != null && !config.getUserSearchBase().isEmpty())|| (config.getUserSearchFilter() != null && !config.getUserSearchFilter().isEmpty())) {
      throw new Exception("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    }
 else {
      throw new Exception(msg + ne);
    }
  }
 finally {
    if (userSearchResultEnum != null) {
      userSearchResultEnum.close();
    }
  }
}