Program: 166208
Project: 166208
Buggy source:
private void goUpGroupHierarchyLdap(Set<String> groupDNs,int groupHierarchyLevels,UserInfo userInfo) throws Throwable {
  LOG.debug("String_Node_Str" + groupDNs);
  if (groupHierarchyLevels <= 0 || groupDNs.isEmpty()) {
    return;
  }
  Set<String> nextLevelGroups=new HashSet<String>();
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  try {
    createLdapContext();
    int total;
    if (pagedResultsEnabled) {
      ldapContext.setRequestControls(new Control[]{new PagedResultsControl(pagedResultsSize,Control.NONCRITICAL)});
    }
    String groupFilter="String_Node_Str" + groupObjectClass + "String_Node_Str";
    if (groupSearchFilter != null && !groupSearchFilter.trim().isEmpty()) {
      String customFilter=groupSearchFilter.trim();
      if (!customFilter.startsWith("String_Node_Str")) {
        customFilter="String_Node_Str" + customFilter + "String_Node_Str";
      }
      groupFilter+=customFilter + "String_Node_Str";
    }
    StringBuilder filter=new StringBuilder();
    for (    String groupDN : groupDNs) {
      filter.append("String_Node_Str").append(groupMemberAttributeName).append("String_Node_Str").append(groupDN).append("String_Node_Str");
    }
    filter.append("String_Node_Str");
    groupFilter+=filter;
    LOG.debug("String_Node_Str" + groupFilter);
    for (    String ou : groupSearchBase) {
      byte[] cookie=null;
      int counter=0;
      try {
        do {
          groupSearchResultEnum=ldapContext.search(ou,groupFilter,groupSearchControls);
          while (groupSearchResultEnum.hasMore()) {
            final SearchResult groupEntry=groupSearchResultEnum.next();
            if (groupEntry == null) {
              if (LOG.isInfoEnabled()) {
                LOG.info("String_Node_Str");
              }
              continue;
            }
            counter++;
            Attribute groupNameAttr=groupEntry.getAttributes().get(groupNameAttribute);
            if (groupNameAttr == null) {
              if (LOG.isInfoEnabled()) {
                LOG.info(groupNameAttribute + "String_Node_Str" + groupEntry.getNameInNamespace()+ "String_Node_Str");
              }
              continue;
            }
            String groupDN=groupEntry.getNameInNamespace();
            nextLevelGroups.add(groupDN);
            String gName=(String)groupNameAttr.get();
            if (groupNameCaseConversionFlag) {
              if (groupNameLowerCaseFlag) {
                gName=gName.toLowerCase();
              }
 else {
                gName=gName.toUpperCase();
              }
            }
            if (groupNameRegExInst != null) {
              gName=groupNameRegExInst.transform(gName);
            }
            userInfo.addGroup(gName);
          }
          Control[] controls=ldapContext.getResponseControls();
          if (controls != null) {
            for (            Control control : controls) {
              if (control instanceof PagedResultsResponseControl) {
                PagedResultsResponseControl prrc=(PagedResultsResponseControl)control;
                total=prrc.getResultSize();
                if (total != 0) {
                  LOG.debug("String_Node_Str" + total);
                }
 else {
                  LOG.debug("String_Node_Str");
                }
                cookie=prrc.getCookie();
              }
            }
          }
 else {
            LOG.debug("String_Node_Str");
          }
          if (pagedResultsEnabled) {
            ldapContext.setRequestControls(new Control[]{new PagedResultsControl(PAGE_SIZE,cookie,Control.CRITICAL)});
          }
        }
 while (cookie != null);
        LOG.info("String_Node_Str" + counter);
      }
 catch (      RuntimeException re) {
        LOG.error("String_Node_Str",re);
        throw re;
      }
catch (      Exception t) {
        LOG.error("String_Node_Str",t);
        LOG.info("String_Node_Str" + counter);
      }
    }
  }
 catch (  RuntimeException re) {
    LOG.error("String_Node_Str",re);
    throw re;
  }
 finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
    closeLdapContext();
  }
  goUpGroupHierarchyLdap(nextLevelGroups,groupHierarchyLevels - 1,userInfo);
}

Fixed version (ground truth):
private void goUpGroupHierarchyLdap(Set<String> groupDNs,int groupHierarchyLevels,UserInfo userInfo) throws Throwable {
  LOG.debug("String_Node_Str" + groupDNs);
  if (groupHierarchyLevels <= 0 || groupDNs.isEmpty()) {
    return;
  }
  Set<String> nextLevelGroups=new HashSet<String>();
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  try {
    createLdapContext();
    int total;
    if (pagedResultsEnabled) {
      ldapContext.setRequestControls(new Control[]{new PagedResultsControl(pagedResultsSize,Control.NONCRITICAL)});
    }
    String groupFilter="String_Node_Str" + groupObjectClass + "String_Node_Str";
    if (groupSearchFilter != null && !groupSearchFilter.trim().isEmpty()) {
      String customFilter=groupSearchFilter.trim();
      if (!customFilter.startsWith("String_Node_Str")) {
        customFilter="String_Node_Str" + customFilter + "String_Node_Str";
      }
      groupFilter+=customFilter + "String_Node_Str";
    }
    StringBuilder filter=new StringBuilder();
    for (    String groupDN : groupDNs) {
      filter.append("String_Node_Str").append(groupMemberAttributeName).append("String_Node_Str").append(groupDN).append("String_Node_Str");
    }
    filter.append("String_Node_Str");
    groupFilter+=config.escapeSearchFilter(filter.toString());
    LOG.debug("String_Node_Str" + groupFilter);
    for (    String ou : groupSearchBase) {
      byte[] cookie=null;
      int counter=0;
      try {
        do {
          groupSearchResultEnum=ldapContext.search(ou,groupFilter,groupSearchControls);
          while (groupSearchResultEnum.hasMore()) {
            final SearchResult groupEntry=groupSearchResultEnum.next();
            if (groupEntry == null) {
              if (LOG.isInfoEnabled()) {
                LOG.info("String_Node_Str");
              }
              continue;
            }
            counter++;
            Attribute groupNameAttr=groupEntry.getAttributes().get(groupNameAttribute);
            if (groupNameAttr == null) {
              if (LOG.isInfoEnabled()) {
                LOG.info(groupNameAttribute + "String_Node_Str" + groupEntry.getNameInNamespace()+ "String_Node_Str");
              }
              continue;
            }
            String groupDN=groupEntry.getNameInNamespace();
            nextLevelGroups.add(groupDN);
            String gName=(String)groupNameAttr.get();
            if (groupNameCaseConversionFlag) {
              if (groupNameLowerCaseFlag) {
                gName=gName.toLowerCase();
              }
 else {
                gName=gName.toUpperCase();
              }
            }
            if (groupNameRegExInst != null) {
              gName=groupNameRegExInst.transform(gName);
            }
            userInfo.addGroup(gName);
          }
          Control[] controls=ldapContext.getResponseControls();
          if (controls != null) {
            for (            Control control : controls) {
              if (control instanceof PagedResultsResponseControl) {
                PagedResultsResponseControl prrc=(PagedResultsResponseControl)control;
                total=prrc.getResultSize();
                if (total != 0) {
                  LOG.debug("String_Node_Str" + total);
                }
 else {
                  LOG.debug("String_Node_Str");
                }
                cookie=prrc.getCookie();
              }
            }
          }
 else {
            LOG.debug("String_Node_Str");
          }
          if (pagedResultsEnabled) {
            ldapContext.setRequestControls(new Control[]{new PagedResultsControl(PAGE_SIZE,cookie,Control.CRITICAL)});
          }
        }
 while (cookie != null);
        LOG.info("String_Node_Str" + counter);
      }
 catch (      RuntimeException re) {
        LOG.error("String_Node_Str",re);
        throw re;
      }
catch (      Exception t) {
        LOG.error("String_Node_Str",t);
        LOG.info("String_Node_Str" + counter);
      }
    }
  }
 catch (  RuntimeException re) {
    LOG.error("String_Node_Str",re);
    throw re;
  }
 finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
    closeLdapContext();
  }
  goUpGroupHierarchyLdap(nextLevelGroups,groupHierarchyLevels - 1,userInfo);
}