Program: 166227
Project: 166227
Buggy source:
private void getGroups(UserGroupSink sink) throws Throwable {
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  try {
    createLdapContext();
    int total;
    if (pagedResultsEnabled) {
      ldapContext.setRequestControls(new Control[]{new PagedResultsControl(pagedResultsSize,Control.NONCRITICAL)});
    }
    extendedGroupSearchFilter="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";
      }
      extendedGroupSearchFilter=extendedGroupSearchFilter + customFilter;
    }
    DateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
    extendedAllGroupsSearchFilter="String_Node_Str" + extendedGroupSearchFilter + "String_Node_Str"+ deltaSyncGroupTime+ "String_Node_Str"+ deltaSyncGroupTimeStamp+ "String_Node_Str";
    LOG.info("String_Node_Str" + extendedAllGroupsSearchFilter);
    long highestdeltaSyncGroupTime=deltaSyncGroupTime;
    for (int ou=0; ou < groupSearchBase.length; ou++) {
      byte[] cookie=null;
      int counter=0;
      try {
        do {
          groupSearchResultEnum=ldapContext.search(groupSearchBase[ou],extendedAllGroupsSearchFilter,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 gName=(String)groupNameAttr.get();
            String transformGroupName=groupNameTransform(gName);
            if (groupSearchFirstEnabled) {
              LOG.debug("String_Node_Str" + transformGroupName);
              sink.addOrUpdateGroup(transformGroupName);
            }
            Attribute timeStampAttr=groupEntry.getAttributes().get("String_Node_Str");
            if (timeStampAttr != null) {
              String uSNChangedVal=(String)timeStampAttr.get();
              long currentDeltaSyncTime=Long.parseLong(uSNChangedVal);
              if (currentDeltaSyncTime > highestdeltaSyncGroupTime) {
                highestdeltaSyncGroupTime=currentDeltaSyncTime;
              }
            }
 else {
              timeStampAttr=groupEntry.getAttributes().get("String_Node_Str");
              if (timeStampAttr != null) {
                String timeStampVal=(String)timeStampAttr.get();
                Date parseDate=dateFormat.parse(timeStampVal);
                long currentDeltaSyncTime=parseDate.getTime();
                LOG.info("String_Node_Str" + timeStampVal + "String_Node_Str"+ currentDeltaSyncTime);
                if (currentDeltaSyncTime > highestdeltaSyncGroupTime) {
                  highestdeltaSyncGroupTime=currentDeltaSyncTime;
                  deltaSyncGroupTimeStamp=timeStampVal;
                }
              }
            }
            Attribute groupMemberAttr=groupEntry.getAttributes().get(groupMemberAttributeName);
            int userCount=0;
            if (groupMemberAttr == null || groupMemberAttr.size() <= 0) {
              LOG.info("String_Node_Str" + gName);
              continue;
            }
            NamingEnumeration<?> userEnum=groupMemberAttr.getAll();
            while (userEnum.hasMore()) {
              String originalUserFullName=(String)userEnum.next();
              if (originalUserFullName == null || originalUserFullName.trim().isEmpty()) {
                continue;
              }
              userCount++;
              String userName=getShortUserName(originalUserFullName);
              if (groupSearchFirstEnabled && !userSearchEnabled) {
                String transformUserName=userNameTransform(userName);
                try {
                  sink.addOrUpdateUser(transformUserName);
                }
 catch (                Throwable t) {
                  LOG.error("String_Node_Str" + t.getMessage() + "String_Node_Str"+ transformUserName);
                }
              }
              groupUserTable.put(gName,userName,userName);
            }
            LOG.info("String_Node_Str" + gName + "String_Node_Str"+ userCount);
          }
          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];
                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 (      Throwable t) {
        LOG.error("String_Node_Str" + t);
        LOG.info("String_Node_Str" + counter);
      }
    }
    if (deltaSyncGroupTime < highestdeltaSyncGroupTime) {
      deltaSyncGroupTime=highestdeltaSyncGroupTime + 1;
      deltaSyncGroupTimeStamp=dateFormat.format(new Date(highestdeltaSyncGroupTime + 60000l));
    }
  }
  finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
    closeLdapContext();
  }
}

Fixed version (ground truth):
private void getGroups(UserGroupSink sink) throws Throwable {
  NamingEnumeration<SearchResult> groupSearchResultEnum=null;
  try {
    createLdapContext();
    int total;
    if (pagedResultsEnabled) {
      ldapContext.setRequestControls(new Control[]{new PagedResultsControl(pagedResultsSize,Control.NONCRITICAL)});
    }
    extendedGroupSearchFilter="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";
      }
      extendedGroupSearchFilter=extendedGroupSearchFilter + customFilter;
    }
    DateFormat dateFormat=new SimpleDateFormat("String_Node_Str");
    extendedAllGroupsSearchFilter="String_Node_Str" + extendedGroupSearchFilter + "String_Node_Str"+ deltaSyncGroupTime+ "String_Node_Str"+ deltaSyncGroupTimeStamp+ "String_Node_Str";
    LOG.info("String_Node_Str" + extendedAllGroupsSearchFilter);
    long highestdeltaSyncGroupTime=deltaSyncGroupTime;
    for (int ou=0; ou < groupSearchBase.length; ou++) {
      byte[] cookie=null;
      int counter=0;
      try {
        do {
          groupSearchResultEnum=ldapContext.search(groupSearchBase[ou],extendedAllGroupsSearchFilter,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 gName=(String)groupNameAttr.get();
            String transformGroupName=groupNameTransform(gName);
            if (groupSearchFirstEnabled) {
              LOG.debug("String_Node_Str" + transformGroupName);
              sink.addOrUpdateGroup(transformGroupName);
            }
            Attribute timeStampAttr=groupEntry.getAttributes().get("String_Node_Str");
            if (timeStampAttr != null) {
              String uSNChangedVal=(String)timeStampAttr.get();
              long currentDeltaSyncTime=Long.parseLong(uSNChangedVal);
              if (currentDeltaSyncTime > highestdeltaSyncGroupTime) {
                highestdeltaSyncGroupTime=currentDeltaSyncTime;
              }
            }
 else {
              timeStampAttr=groupEntry.getAttributes().get("String_Node_Str");
              if (timeStampAttr != null) {
                String timeStampVal=(String)timeStampAttr.get();
                Date parseDate=dateFormat.parse(timeStampVal);
                long currentDeltaSyncTime=parseDate.getTime();
                LOG.info("String_Node_Str" + timeStampVal + "String_Node_Str"+ currentDeltaSyncTime);
                if (currentDeltaSyncTime > highestdeltaSyncGroupTime) {
                  highestdeltaSyncGroupTime=currentDeltaSyncTime;
                  deltaSyncGroupTimeStamp=timeStampVal;
                }
              }
            }
            Attribute groupMemberAttr=groupEntry.getAttributes().get(groupMemberAttributeName);
            int userCount=0;
            if (groupMemberAttr == null || groupMemberAttr.size() <= 0) {
              LOG.info("String_Node_Str" + gName);
              continue;
            }
            NamingEnumeration<?> userEnum=groupMemberAttr.getAll();
            while (userEnum.hasMore()) {
              String originalUserFullName=(String)userEnum.next();
              if (originalUserFullName == null || originalUserFullName.trim().isEmpty()) {
                continue;
              }
              userCount++;
              String userName=getShortUserName(originalUserFullName);
              originalUserFullName=originalUserFullName.toLowerCase();
              if (groupSearchFirstEnabled && !userSearchEnabled) {
                String transformUserName=userNameTransform(userName);
                try {
                  sink.addOrUpdateUser(transformUserName);
                }
 catch (                Throwable t) {
                  LOG.error("String_Node_Str" + t.getMessage() + "String_Node_Str"+ transformUserName);
                }
                userNameMap.put(originalUserFullName,transformUserName);
              }
              if (userNameMap.get(originalUserFullName) != null) {
                groupUserTable.put(gName,originalUserFullName,userNameMap.get(originalUserFullName));
              }
 else {
                groupUserTable.put(gName,originalUserFullName,originalUserFullName);
              }
            }
            LOG.info("String_Node_Str" + gName + "String_Node_Str"+ userCount);
          }
          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];
                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 (      Exception t) {
        LOG.error("String_Node_Str" + t);
        LOG.info("String_Node_Str" + counter);
      }
    }
    if (deltaSyncGroupTime < highestdeltaSyncGroupTime) {
      deltaSyncGroupTime=highestdeltaSyncGroupTime + 1;
      deltaSyncGroupTimeStamp=dateFormat.format(new Date(highestdeltaSyncGroupTime + 60000l));
    }
  }
  finally {
    if (groupSearchResultEnum != null) {
      groupSearchResultEnum.close();
    }
    closeLdapContext();
  }
}