nus-yam/ex-repair huggingface dataset:
Program: 86971
Project: 86971
Buggy source:
/** 
 * Internal method to check for Services or create Services.
 * @param name
 * @param c
 * @return the found service, null if no T can be created.
 * @throws InvocationTargetException
 */
@SuppressWarnings("String_Node_Str") protected <T>T locate(final String askedName,final Class<T> c) throws InvocationTargetException {
  if (ICS.class.isAssignableFrom(c)) {
    return (T)ics;
  }
  if (c.isArray()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final String name=StringUtils.isNotBlank(askedName) ? askedName : c.getSimpleName();
  if (StringUtils.isBlank(name)) {
    return null;
  }
  Object o=objectCache.get(name);
  if (o != null && !o.getClass().isAssignableFrom(c))   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str"+ o.getClass()+ "String_Node_Str"+ c.getName()+ "String_Node_Str");
  if (o == null) {
    o=namedAnnotationStrategy(name,c);
  }
  if (o == null) {
    o=unnamedAnnotationStrategy(name,c);
  }
  if (o == null) {
    o=reflectionStrategy(name,c);
  }
  return (T)o;
}

Fixed version (ground truth):
/** 
 * Internal method to check for Services or create Services.
 * @param name
 * @param c
 * @return the found service, null if no T can be created.
 * @throws InvocationTargetException
 */
@SuppressWarnings("String_Node_Str") protected <T>T locate(final String askedName,final Class<T> c) throws InvocationTargetException {
  if (ICS.class.isAssignableFrom(c)) {
    return (T)ics;
  }
  if (c.isArray()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final String name=StringUtils.isNotBlank(askedName) ? askedName : c.getSimpleName();
  if (StringUtils.isBlank(name)) {
    return null;
  }
  Object o=objectCache.get(name);
  if (o != null && !c.isAssignableFrom(o.getClass()))   throw new IllegalStateException("String_Node_Str" + name + "String_Node_Str"+ o.getClass()+ "String_Node_Str"+ c.getName()+ "String_Node_Str");
  if (o == null) {
    o=namedAnnotationStrategy(name,c);
  }
  if (o == null) {
    o=unnamedAnnotationStrategy(name,c);
  }
  if (o == null) {
    o=reflectionStrategy(name,c);
  }
  return (T)o;
}
Program: 86973
Project: 86973
Buggy source:
@SuppressWarnings("String_Node_Str") protected <T>T locate(final Class<T> c,final ICS ics){
  if (ICS.class.isAssignableFrom(c)) {
    return (T)ics;
  }
  if (c.isArray()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final String name=c.getSimpleName();
  if (StringUtils.isBlank(name)) {
    return null;
  }
  Object o=objectCache.get(name);
  if (o == null) {
    try {
      Method m;
      m=getClass().getMethod("String_Node_Str" + name,ICS.class);
      if (m != null) {
        o=m.invoke(this,ics);
      }
    }
 catch (    final NoSuchMethodException e) {
      try {
        LOG.debug("String_Node_Str" + c.getName() + "String_Node_Str");
        final Constructor<T> constr=c.getConstructor(ICS.class);
        o=constr.newInstance(ics);
      }
 catch (      final RuntimeException e1) {
        throw e1;
      }
catch (      final Exception e1) {
        throw new RuntimeException(e1);
      }
    }
catch (    final RuntimeException e) {
      throw e;
    }
catch (    final Exception e) {
      throw new RuntimeException(e);
    }
    if (shouldCache(c)) {
      objectCache.put(c.getName(),o);
    }
  }
  return (T)o;
}

Fixed version (ground truth):
/** 
 * Internal method to check for Services or create Services.
 * @param c
 * @param ics
 * @return the found service, null if no T can be created.
 */
@SuppressWarnings("String_Node_Str") protected <T>T locate(final Class<T> c,final ICS ics){
  if (ICS.class.isAssignableFrom(c)) {
    return (T)ics;
  }
  if (c.isArray()) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  final String name=c.getSimpleName();
  if (StringUtils.isBlank(name)) {
    return null;
  }
  Object o=objectCache.get(name);
  if (o == null) {
    try {
      Method m;
      m=getClass().getMethod("String_Node_Str" + name,ICS.class);
      if (m != null) {
        if (LOG.isTraceEnabled())         LOG.trace("String_Node_Str" + name + "String_Node_Str"+ m.getName());
        o=m.invoke(this,ics);
      }
    }
 catch (    final NoSuchMethodException e) {
      try {
        LOG.debug("String_Node_Str" + c.getName() + "String_Node_Str");
        final Constructor<T> constr=c.getConstructor(ICS.class);
        o=constr.newInstance(ics);
      }
 catch (      final RuntimeException e1) {
        throw e1;
      }
catch (      final Exception e1) {
        throw new RuntimeException(e1);
      }
    }
catch (    final RuntimeException e) {
      throw e;
    }
catch (    final Exception e) {
      throw new RuntimeException(e);
    }
    if (shouldCache(c)) {
      objectCache.put(c.getName(),o);
    }
  }
  return (T)o;
}
Program: 86974
Project: 86974
Buggy source:
public NavigationService createNavigationService(final ICS ics){
  boolean wraNavigationSupport=true;
  if (wraNavigationSupport) {
    DimensionFilterInstance filter=getDimensionFilter(ics);
    if (filter == null) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("String_Node_Str");
      }
      return null;
    }
    AliasCoreFieldDao aliasDao=locate(AliasCoreFieldDao.class,ics);
    Date date=PreviewContext.getPreviewDateFromCSVar(ics,"String_Node_Str");
    return new WraNavigationService(ics,locate(TemplateAssetAccess.class,ics),aliasDao,filter,date);
  }
 else {
    return new SimpleNavigationHelper(ics,locate(TemplateAssetAccess.class,ics),"String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
public NavigationService createNavigationService(final ICS ics){
  boolean wraNavigationSupport=true;
  if (wraNavigationSupport) {
    DimensionFilterInstance filter=getDimensionFilter(ics);
    if (filter == null && LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str");
    }
    AliasCoreFieldDao aliasDao=locate(AliasCoreFieldDao.class,ics);
    Date date=PreviewContext.getPreviewDateFromCSVar(ics,"String_Node_Str");
    return new WraNavigationService(ics,locate(TemplateAssetAccess.class,ics),aliasDao,filter,date);
  }
 else {
    return new SimpleNavigationHelper(ics,locate(TemplateAssetAccess.class,ics),"String_Node_Str","String_Node_Str");
  }
}
Program: 86975
Project: 86975
Buggy source:
@Override public void doTag() throws JspException, IOException {
  super.doTag();
  final ICS ics=(ICS)getICS();
  final NavigationService nh=getService("String_Node_Str",NavigationService.class);
  String site=ics.GetVar("String_Node_Str");
  if (StringUtils.isBlank(site))   throw new IllegalStateException("String_Node_Str");
  if (StringUtils.isBlank(pagename)) {
    Collection<NavigationNode> nav=nh.getRootNodesForSite(site,depth);
    getJspContext().setAttribute(name,nav);
  }
 else {
    NavigationNode nav=nh.getNodeByName(pagename,site,depth);
    getJspContext().setAttribute(name,nav);
  }
  depth=1;
  pagename=null;
}

Fixed version (ground truth):
@Override public void doTag() throws JspException, IOException {
  super.doTag();
  final ICS ics=(ICS)getICS();
  final NavigationService nh=getService("String_Node_Str",NavigationService.class);
  if (nh == null)   throw new IllegalStateException("String_Node_Str");
  String site=ics.GetVar("String_Node_Str");
  if (StringUtils.isBlank(site))   throw new IllegalStateException("String_Node_Str");
  if (StringUtils.isBlank(pagename)) {
    Collection<NavigationNode> nav=nh.getRootNodesForSite(site,depth);
    getJspContext().setAttribute(name,nav);
  }
 else {
    NavigationNode nav=nh.getNodeByName(pagename,site,depth);
    getJspContext().setAttribute(name,nav);
  }
  depth=1;
  pagename=null;
}
Program: 86976
Project: 86976
Buggy source:
private final DimensionSetInstance getDimensionSet(ICS ics){
  try {
    String site=ics.GetVar("String_Node_Str");
    if (StringUtils.isNotBlank(site)) {
      long discoveredId=LocaleUtils.locateDimensionSetForSite(ics,site);
      LOG.trace("String_Node_Str" + site + "String_Node_Str"+ discoveredId);
      return LocaleUtils.getDimensionSet(ics,discoveredId);
    }
  }
 catch (  RuntimeException e) {
    LOG.trace("String_Node_Str" + e);
  }
  throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
protected final DimensionSetInstance getDimensionSet(ICS ics){
  try {
    String site=ics.GetVar("String_Node_Str");
    if (StringUtils.isNotBlank(site)) {
      long discoveredId=LocaleUtils.locateDimensionSetForSite(ics,site);
      LOG.trace("String_Node_Str" + site + "String_Node_Str"+ discoveredId);
      return LocaleUtils.getDimensionSet(ics,discoveredId);
    }
  }
 catch (  RuntimeException e) {
    LOG.trace("String_Node_Str" + e);
  }
  return null;
}
Program: 86978
Project: 86978
Buggy source:
public NavigationService createNavigationService(final ICS ics){
  boolean wraNavigationSupport=true;
  if (wraNavigationSupport) {
    DimensionFilterInstance filter=getDimensionFilter(ics);
    AliasCoreFieldDao aliasDao=locate(AliasCoreFieldDao.class,ics);
    Date date=PreviewContext.getPreviewDateFromCSVar(ics,"String_Node_Str");
    return new WraNavigationService(ics,locate(TemplateAssetAccess.class,ics),aliasDao,filter,date);
  }
 else {
    return new SimpleNavigationHelper(ics,locate(TemplateAssetAccess.class,ics),"String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
public NavigationService createNavigationService(final ICS ics){
  boolean wraNavigationSupport=true;
  if (wraNavigationSupport) {
    DimensionFilterInstance filter=getDimensionFilter(ics);
    if (filter == null) {
      if (LOG.isTraceEnabled()) {
        LOG.trace("String_Node_Str");
      }
      return null;
    }
    AliasCoreFieldDao aliasDao=locate(AliasCoreFieldDao.class,ics);
    Date date=PreviewContext.getPreviewDateFromCSVar(ics,"String_Node_Str");
    return new WraNavigationService(ics,locate(TemplateAssetAccess.class,ics),aliasDao,filter,date);
  }
 else {
    return new SimpleNavigationHelper(ics,locate(TemplateAssetAccess.class,ics),"String_Node_Str","String_Node_Str");
  }
}
Program: 86979
Project: 86979
Buggy source:
/** 
 * @param site
 * @param depth
 * @param linkAttribute
 * @return
 */
Collection<NavigationNode> getRootNodesForSite(String site,int depth,String linkAttribute);

Fixed version (ground truth):
/** 
 * @param site
 * @param depth the maximum number of levels to retrieve
 * @param linkAttribute
 * @return
 */
Collection<NavigationNode> getRootNodesForSite(String site,int depth,String linkAttribute);
Program: 86980
Project: 86980
Buggy source:
/** 
 * @param pagename
 * @param site
 * @return the NavigationNode for the page by this name.
 */
NavigationNode getNodeByName(String pagename,String site,int depth,String linkAttribute);

Fixed version (ground truth):
/** 
 * Retrieves the NavigationNodes for the Page with the name <tt>pagename</tt> and in the current site. 
 * @param pagename the name of the Page asset
 * @param depth the maximum number of levels to retrieve
 * @param linkAttribute
 * @return the NavigationNode for the page by this name.
 */
NavigationNode getNodeByName(String pagename,int depth,String linkAttribute);
Program: 86981
Project: 86981
Buggy source:
protected String getUrl(TemplateAsset asset){
  String template=asset.asString("String_Node_Str");
  String path=asset.asString(pathAttribute);
  if (StringUtils.isBlank(template)) {
    LOG.warn("String_Node_Str" + asset.getAssetId() + "String_Node_Str");
    return null;
  }
  if (StringUtils.isBlank(path)) {
    LOG.warn("String_Node_Str" + asset.getAssetId() + "String_Node_Str");
    return new TemplateUriBuilder(asset.getAssetId(),template).toURI(ics);
  }
  String wrapper=ics.GetProperty("String_Node_Str","String_Node_Str",true);
  if (!Utilities.goodString(wrapper)) {
    wrapper="String_Node_Str";
  }
  return new WraUriBuilder(asset.getAssetId()).wrapper(wrapper).template(template).toURI(ics);
}

Fixed version (ground truth):
protected String getUrl(TemplateAsset asset){
  String template=asset.asString("String_Node_Str");
  String path=asset.asString(pathAttribute);
  if (StringUtils.isBlank(template)) {
    LOG.debug("String_Node_Str" + asset.getAssetId() + "String_Node_Str");
    return null;
  }
  if (StringUtils.isBlank(path)) {
    LOG.debug("String_Node_Str" + asset.getAssetId() + "String_Node_Str");
    return new TemplateUriBuilder(asset.getAssetId(),template).toURI(ics);
  }
  String wrapper=ics.GetProperty("String_Node_Str","String_Node_Str",true);
  if (!Utilities.goodString(wrapper)) {
    wrapper="String_Node_Str";
  }
  return new WraUriBuilder(asset.getAssetId()).wrapper(wrapper).template(template).toURI(ics);
}
Program: 86982
Project: 86982
Buggy source:
/** 
 * List all the Page assets at this SitePlanTree nodeId.
 * @param nodeId the nodeId from the SitePlanTree
 * @param level the tree level depth
 * @param depth the maximum depth
 * @return
 */
protected Collection<NavigationNode> getNodeChildren(final long nodeId,final int level,final int depth,String linkAttribute){
  StatementParam param=CHILD_STMT.newParam();
  param.setLong(0,nodeId);
  IListIterable root=SqlHelper.select(ics,CHILD_STMT,param);
  List<NavigationNode> collection=new LinkedList<NavigationNode>();
  for (  Row row : root) {
    long nid=row.getLong("String_Node_Str");
    long pageId=row.getLong("String_Node_Str");
    AssetId pid=assetTemplate.createAssetId(row.getString("String_Node_Str"),pageId);
    LogDep.logDep(ics,pid);
    TemplateAsset asset=assetTemplate.read(pid,"String_Node_Str","String_Node_Str","String_Node_Str",pathAttribute,linkAttribute);
    final NavigationNode node=new NavigationNode();
    node.setPage(pid);
    node.setLevel(level);
    node.setPagesubtype(asset.getSubtype());
    node.setPagename(asset.asString("String_Node_Str"));
    node.setId(asset.getAssetId());
    final String url=getUrl(asset);
    if (url != null) {
      node.setUrl(url);
    }
    final String linktext=asset.asString(linkAttribute);
    if (linktext != null) {
      node.setLinktext(linktext);
    }
 else {
      node.setLinktext(asset.asString("String_Node_Str"));
    }
    if (depth < 0 || depth > level) {
      Collection<NavigationNode> children=getNodeChildren(nid,level + 1,depth,linkAttribute);
      for (      final NavigationNode kid : children) {
        if (kid != null && kid.getPage() != null) {
          node.addChild(kid);
        }
      }
    }
  }
  return collection;
}

Fixed version (ground truth):
/** 
 * List all the child NavigationNode at this SitePlanTree nodeId.
 * @param nodeId the nodeId from the SitePlanTree
 * @param level the tree level depth
 * @param depth the maximum depth
 * @return
 */
protected Collection<NavigationNode> getNodeChildren(final long nodeId,final int level,final int depth,String linkAttribute){
  StatementParam param=CHILD_STMT.newParam();
  param.setLong(0,nodeId);
  IListIterable root=SqlHelper.select(ics,CHILD_STMT,param);
  List<NavigationNode> collection=new LinkedList<NavigationNode>();
  for (  Row row : root) {
    final NavigationNode node=getNode(row,level,depth,linkAttribute);
    if (node != null)     collection.add(node);
  }
  return collection;
}
Program: 86983
Project: 86983
Buggy source:
public SimpleNavigationHelper(ICS ics,TemplateAssetAccess assetTemplate,String linkLabelAttribute,String pathAttribute){
  if (StringUtils.isBlank(linkLabelAttribute))   throw new IllegalArgumentException("String_Node_Str");
  if (StringUtils.isBlank(pathAttribute))   throw new IllegalArgumentException("String_Node_Str");
  this.ics=ics;
  this.assetTemplate=assetTemplate;
  this.pathAttribute=pathAttribute;
  this.linkLabelAttribute=linkLabelAttribute;
}

Fixed version (ground truth):
/** 
 * Constructor that sets the linkLabel and path attributes.
 * @param ics
 * @param assetTemplate
 * @param linkLabelAttribute
 * @param pathAttribute
 */
public SimpleNavigationHelper(ICS ics,TemplateAssetAccess assetTemplate,String linkLabelAttribute,String pathAttribute){
  if (StringUtils.isBlank(linkLabelAttribute))   throw new IllegalArgumentException("String_Node_Str");
  if (StringUtils.isBlank(pathAttribute))   throw new IllegalArgumentException("String_Node_Str");
  this.ics=ics;
  this.assetTemplate=assetTemplate;
  this.pathAttribute=pathAttribute;
  this.linkLabelAttribute=linkLabelAttribute;
}
Program: 86984
Project: 86984
Buggy source:
@Override public NavigationNode getNodeByName(String pagename,int depth){
  return getNodeByName(pagename,ics.GetVar("String_Node_Str"),depth);
}

Fixed version (ground truth):
@Override public NavigationNode getNodeByName(String pagename,int depth){
  return getNodeByName(ics.GetVar("String_Node_Str"),pagename,depth);
}
Program: 86985
Project: 86985
Buggy source:
private static void put(Object object,Field field,String var) throws IllegalAccessException {
  if (StringUtils.isBlank(var))   return;
  if (field.getType().isPrimitive()) {
    putPrimitive(object,field,var);
  }
  Object value=null;
  if (field.getType() == String.class) {
    value=var;
  }
 else   if (field.getType() == Date.class) {
    value=Util.parseJdbcDate(var);
  }
 else   if (field.getType() == Integer.class) {
    value=new Integer(var);
  }
 else   if (field.getType() == Double.class) {
    value=new Double(var);
  }
 else   if (field.getType() == Character.class) {
    value=new Character(var.charAt(0));
  }
 else   if (field.getType() == Long.class) {
    value=new Long(var);
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + value + "String_Node_Str"+ field.getName()+ "String_Node_Str"+ object.getClass().getName());
  }
  try {
    field.set(object,value);
  }
 catch (  final IllegalArgumentException e) {
    throw new IllegalArgumentException("String_Node_Str" + value + "String_Node_Str"+ field.getName(),e);
  }
catch (  final IllegalAccessException e) {
    throw new IllegalAccessException("String_Node_Str" + value + "String_Node_Str"+ field.getName());
  }
}

Fixed version (ground truth):
private static void put(Object object,Field field,String var) throws IllegalAccessException {
  if (StringUtils.isBlank(var))   return;
  if (field.getType().isPrimitive()) {
    putPrimitive(object,field,var);
  }
 else {
    Object value=null;
    if (field.getType() == String.class) {
      value=var;
    }
 else     if (field.getType() == Date.class) {
      value=Util.parseJdbcDate(var);
    }
 else     if (field.getType() == Integer.class) {
      value=new Integer(var);
    }
 else     if (field.getType() == Double.class) {
      value=new Double(var);
    }
 else     if (field.getType() == Character.class) {
      value=new Character(var.charAt(0));
    }
 else     if (field.getType() == Long.class) {
      value=new Long(var);
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + value + "String_Node_Str"+ field.getName()+ "String_Node_Str"+ object.getClass().getName());
    }
    try {
      field.set(object,value);
    }
 catch (    final IllegalArgumentException e) {
      throw new IllegalArgumentException("String_Node_Str" + value + "String_Node_Str"+ field.getName(),e);
    }
catch (    final IllegalAccessException e) {
      throw new IllegalAccessException("String_Node_Str" + value + "String_Node_Str"+ field.getName());
    }
  }
}
Program: 86986
Project: 86986
Buggy source:
/** 
 * Main dimension filtering method.  Accesses the filter in the dimension set, configures it with the preferred dimension IDs, then filters the input assets.
 * @param dimensionManager      manager class for Dimension lookups
 * @param toFilterList          list of input assets that need to be filtered.  Often it's just one, but a list is perfectly valid.
 * @param preferredDimensionIds preferred dimensions to be investigated for a result. Priority preference depends on theconfigured filter
 * @param dimSet                DimensionSet to use for filtering.
 * @return list of assets based on the filtering rules in the dimension filter from the specified dimension set.
 * @throws DimensionException in case something goes terribly wrong.
 */
public static Collection<AssetId> filterAssets(DimensionManager dimensionManager,List<AssetId> toFilterList,Collection<AssetId> preferredDimensionIds,DimensionSetInstance dimSet) throws DimensionException {
  List<Dimension> preferredDimensions=dimensionManager.loadDimensions(preferredDimensionIds);
  DimensionFilterInstance filter=dimSet.getFilter();
  filter.setDimensonPreference(preferredDimensions);
  return filter.filterAssets(toFilterList);
}

Fixed version (ground truth):
/** 
 * Main dimension filtering method.  Accesses the filter in the dimension set, configures it with the preferred dimension IDs, then filters the input assets.
 * @param dimensionManager      manager class for Dimension lookups
 * @param toFilterList          list of input assets that need to be filtered.  Often it's just one, but a list is perfectly valid.
 * @param preferredDimensionIds preferred dimensions to be investigated for a result. Priority preference depends on theconfigured filter
 * @param dimSet                DimensionSet to use for filtering.
 * @return list of assets based on the filtering rules in the dimension filter from the specified dimension set.
 * @throws DimensionException in case something goes terribly wrong.
 */
public static Collection<AssetId> filterAssets(DimensionManager dimensionManager,List<AssetId> toFilterList,Collection<AssetId> preferredDimensionIds,DimensionSetInstance dimSet) throws DimensionException {
  List<Dimension> preferredDimensions=dimensionManager.loadDimensions(preferredDimensionIds);
  if (_log.isTraceEnabled())   _log.trace("String_Node_Str" + preferredDimensions.size());
  DimensionFilterInstance filter=dimSet.getFilter();
  if (_log.isTraceEnabled())   _log.trace("String_Node_Str" + (filter != null));
  filter.setDimensonPreference(preferredDimensions);
  Collection<AssetId> result=filter.filterAssets(toFilterList);
  if (_log.isDebugEnabled())   _log.debug("String_Node_Str" + toFilterList + "String_Node_Str"+ dimSet+ "String_Node_Str"+ preferredDimensionIds+ "String_Node_Str"+ result);
  return filter.filterAssets(toFilterList);
}
Program: 86987
Project: 86987
Buggy source:
/** 
 * Locates a single dimension set in a site. If no match is found, an exception is thrown. If more than one match is found, an exception is thrown.
 * @param ics context
 * @param site site containing a dimension set
 * @return DimensionSet ID
 */
private static long _locateDimensionSetForSite(ICS ics,String site){
  if (site == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  StatementParam params=FIND_DIMSET_FOR_SITE_PREPAREDSTMT.newParam();
  params.setString(0,site);
  IList results=ics.SQL(FIND_DIMSET_FOR_SITE_PREPAREDSTMT,params,true);
  int numRows=results != null && results.hasData() ? results.numRows() : 0;
  if (numRows == 0) {
    throw new IllegalStateException("String_Node_Str" + site + "String_Node_Str");
  }
  if (numRows > 1) {
    String msg="String_Node_Str" + site + "String_Node_Str";
    for (    IList row : new IterableIListWrapper(results)) {
      String id=IListUtils.getStringValue(row,"String_Node_Str");
      LogDep.logDep(ics,"String_Node_Str",id);
      msg+=id + "String_Node_Str";
    }
    throw new IllegalStateException(msg + "String_Node_Str");
  }
  results.moveTo(1);
  String id=IListUtils.getStringValue(results,"String_Node_Str");
  LogDep.logDep(ics,"String_Node_Str",id);
  return Long.valueOf(id);
}

Fixed version (ground truth):
/** 
 * Locates a single dimension set in a site. If no match is found, an exception is thrown. If more than one match is found, an exception is thrown.
 * @param ics context
 * @param site site containing a dimension set
 * @return DimensionSet ID
 */
private static long _locateDimensionSetForSite(ICS ics,String site){
  if (site == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  StatementParam params=FIND_DIMSET_FOR_SITE_PREPAREDSTMT.newParam();
  params.setString(0,site);
  IList results=ics.SQL(FIND_DIMSET_FOR_SITE_PREPAREDSTMT,params,true);
  int numRows=results != null && results.hasData() ? results.numRows() : 0;
  if (numRows == 0) {
    throw new IllegalStateException("String_Node_Str" + site + "String_Node_Str");
  }
  if (numRows > 1) {
    String msg="String_Node_Str" + site + "String_Node_Str";
    for (    IList row : new IterableIListWrapper(results)) {
      String id=IListUtils.getStringValue(row,"String_Node_Str");
      LogDep.logDep(ics,"String_Node_Str",id);
      msg+=id + "String_Node_Str";
    }
    throw new IllegalStateException(msg + "String_Node_Str");
  }
  results.moveTo(1);
  String id=IListUtils.getStringValue(results,"String_Node_Str");
  LogDep.logDep(ics,"String_Node_Str",id);
  if (_log.isTraceEnabled())   _log.trace("String_Node_Str" + site + "String_Node_Str"+ id);
  return Long.valueOf(id);
}
Program: 86989
Project: 86989
Buggy source:
/** 
 * @param ics Content Server context
 * @param asset asset to render
 * @param tname template name
 */
public IncludeTemplate(final ICS ics,final AssetId asset,final String tname){
  this.ics=ics;
  tag=new CallTemplate();
  tag.setTname(tname);
  final String eid=ics.GetVar("String_Node_Str");
  if (eid != null) {
    tag.setTid(eid);
    tag.setTtype(Type.CSElement);
  }
 else {
    tag.setTid(ics.GetVar("String_Node_Str"));
    tag.setTtype(Type.Template);
  }
  tag.setContext("String_Node_Str");
  final String site=ics.GetVar("String_Node_Str");
  tag.setSite(site);
  final String packedargs=ics.GetVar("String_Node_Str");
  if (packedargs != null && packedargs.length() > 0) {
    tag.setPackedargs(packedargs);
  }
  tag.setAsset(asset);
  tag.setFixPageCriteria(false);
  tag.setSlotname("String_Node_Str");
  final String target=tname.startsWith("String_Node_Str") ? site + "String_Node_Str" + tname : site + "String_Node_Str" + asset.getType()+ "String_Node_Str"+ tname;
  final String[] keys=ics.pageCriteriaKeys(target);
  if (keys == null) {
    throw new IllegalArgumentException("String_Node_Str" + target + "String_Node_Str"+ target+ "String_Node_Str");
  }
  pc=Arrays.asList(keys);
  for (  final String k : keys) {
    if (!FORBIDDEN_VARS.contains(k)) {
      final String v=ics.GetVar(k);
      if (StringUtils.isNotBlank(v)) {
        argument(k,v);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param ics Content Server context
 * @param asset asset to render
 * @param tname template name
 */
public IncludeTemplate(final ICS ics,final AssetId asset,final String tname){
  this.ics=ics;
  tag=new CallTemplate();
  tag.setTname(tname);
  final String eid=ics.GetVar("String_Node_Str");
  if (eid != null) {
    tag.setTid(eid);
    tag.setTtype(Type.CSElement);
  }
 else {
    tag.setTid(ics.GetVar("String_Node_Str"));
    tag.setTtype(Type.Template);
  }
  tag.setContext("String_Node_Str");
  final String site=ics.GetVar("String_Node_Str");
  tag.setSite(site);
  final String packedargs=ics.GetVar("String_Node_Str");
  if (packedargs != null && packedargs.length() > 0) {
    tag.setPackedargs(packedargs);
  }
  tag.setAsset(asset);
  tag.setFixPageCriteria(false);
  tag.setSlotname("String_Node_Str");
  final String target=tname.startsWith("String_Node_Str") ? site + tname : site + "String_Node_Str" + asset.getType()+ "String_Node_Str"+ tname;
  final String[] keys=ics.pageCriteriaKeys(target);
  if (keys == null) {
    throw new IllegalArgumentException("String_Node_Str" + target + "String_Node_Str"+ target+ "String_Node_Str");
  }
  pc=Arrays.asList(keys);
  for (  final String k : keys) {
    if (!FORBIDDEN_VARS.contains(k)) {
      final String v=ics.GetVar(k);
      if (StringUtils.isNotBlank(v)) {
        argument(k,v);
      }
    }
  }
}
Program: 86990
Project: 86990
Buggy source:
protected void callTemplate(final AssetIdWithSite id,final String tname){
  final CallTemplate ct=new CallTemplate();
  ct.setSite(id.getSite());
  ct.setSlotname("String_Node_Str");
  ct.setTid(ics.GetVar("String_Node_Str"));
  ct.setAsset(id);
  ct.setTname(tname);
  ct.setContext("String_Node_Str");
  ct.setArgument("String_Node_Str",id.getSite());
  final String packedargs=ics.GetVar("String_Node_Str");
  if (packedargs != null && packedargs.length() > 0) {
    ct.setPackedargs(packedargs);
  }
  final String targetPagename=tname.startsWith("String_Node_Str") ? id.getSite() + "String_Node_Str" + tname : id.getSite() + "String_Node_Str" + id.getType()+ "String_Node_Str"+ tname;
  final Map<String,String> arguments=new HashMap<String,String>();
  for (  final String pcVarName : ics.pageCriteriaKeys(targetPagename)) {
    if (!CALLTEMPLATE_EXCLUDE_VARS.contains(pcVarName) && StringUtils.isNotBlank(ics.GetVar(pcVarName))) {
      arguments.put(pcVarName,ics.GetVar(pcVarName));
    }
  }
  getCallTemplateArguments(id,arguments);
  for (  final Entry<String,String> e : arguments.entrySet()) {
    ct.setArgument(e.getKey(),e.getValue());
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str" + e.getKey() + "String_Node_Str"+ e.getValue());
    }
  }
  imposeCallTemplateStyle(ct,targetPagename);
  final String s=ct.execute(ics);
  if (s != null) {
    ics.StreamText(s);
  }
}

Fixed version (ground truth):
protected void callTemplate(final AssetIdWithSite id,final String tname){
  final CallTemplate ct=new CallTemplate();
  ct.setSite(id.getSite());
  ct.setSlotname("String_Node_Str");
  ct.setTid(ics.GetVar("String_Node_Str"));
  ct.setAsset(id);
  ct.setTname(tname);
  ct.setContext("String_Node_Str");
  ct.setArgument("String_Node_Str",id.getSite());
  final String packedargs=ics.GetVar("String_Node_Str");
  if (packedargs != null && packedargs.length() > 0) {
    ct.setPackedargs(packedargs);
  }
  final String targetPagename=tname.startsWith("String_Node_Str") ? (id.getSite() + tname) : (id.getSite() + "String_Node_Str" + id.getType()+ "String_Node_Str"+ tname);
  final Map<String,String> arguments=new HashMap<String,String>();
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + targetPagename);
  }
  String[] pageKeys=ics.pageCriteriaKeys(targetPagename);
  if (pageKeys != null) {
    for (    final String pcVarName : pageKeys) {
      if (!CALLTEMPLATE_EXCLUDE_VARS.contains(pcVarName) && StringUtils.isNotBlank(ics.GetVar(pcVarName))) {
        arguments.put(pcVarName,ics.GetVar(pcVarName));
      }
    }
  }
 else {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + targetPagename + "String_Node_Str");
    }
  }
  getCallTemplateArguments(id,arguments);
  for (  final Entry<String,String> e : arguments.entrySet()) {
    ct.setArgument(e.getKey(),e.getValue());
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str" + e.getKey() + "String_Node_Str"+ e.getValue());
    }
  }
  imposeCallTemplateStyle(ct,targetPagename);
  final String s=ct.execute(ics);
  if (s != null) {
    ics.StreamText(s);
  }
}
Program: 86991
Project: 86991
Buggy source:
/** 
 * Adds the key/value pair, where are the value is added as a list.
 * @param key
 * @param value
 */
@SuppressWarnings("String_Node_Str") public void list(String key,Object value){
  Object v=map.get(key);
  if (v instanceof Collection<?>) {
    Collection<Object> l=(Collection<Object>)v;
    l.add(value);
  }
 else {
    Collection<Object> l=new LinkedList<Object>();
    if (v != null)     l.add(v);
    l.add(value);
  }
}

Fixed version (ground truth):
/** 
 * Adds the key/value pair, where are the value is added as a list.
 * @param key
 * @param value
 */
@SuppressWarnings("String_Node_Str") public void list(String key,Object value){
  Object v=map.get(key);
  if (v instanceof Collection<?>) {
    Collection<Object> l=(Collection<Object>)v;
    l.add(value);
  }
 else {
    Collection<Object> l=new LinkedList<Object>();
    if (v != null)     l.add(v);
    l.add(value);
    map.put(key,l);
  }
}
Program: 86992
Project: 86992
Buggy source:
/** 
 * Copies the ics variables identified by the name array  
 * @param name
 * @return this
 */
public IncludeElement copyArguments(final String... name){
  if (name == null) {
    return this;
  }
  for (  final String n : name) {
    argument(n,ics.GetVar(n));
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Copies the ics variables identified by the name array
 * @param name
 * @return this
 */
public IncludeElement copyArguments(final String... name){
  if (name == null) {
    return this;
  }
  for (  final String n : name) {
    argument(n,ics.GetVar(n));
  }
  return this;
}
Program: 86993
Project: 86993
Buggy source:
@SuppressWarnings("String_Node_Str") private void checkPageCriteria(final ICS ics,final String target){
  final FTValList o=getList();
  if (o instanceof Map) {
    String[] pc=ics.pageCriteriaKeys(target);
    if (pc == null) {
      pc=new String[0];
    }
    final Map<String,?> m=o;
    for (final Iterator<?> i=m.entrySet().iterator(); i.hasNext(); ) {
      final Entry<String,?> e=(Entry<String,?>)i.next();
      final String key=e.getKey();
      boolean found=CALLTEMPLATE_EXCLUDE_VARS.contains(key);
      if (!found) {
        for (        final String c : pc) {
          if (c.equalsIgnoreCase(key)) {
            found=true;
            break;
          }
 else           if ((ARGS + c).equalsIgnoreCase(key)) {
            found=true;
            break;
          }
        }
      }
      if (!found) {
        LOG.error("String_Node_Str" + key + "String_Node_Str"+ target+ "String_Node_Str"+ ics.ResolveVariables("String_Node_Str")+ "String_Node_Str"+ m.keySet().toString()+ "String_Node_Str"+ Arrays.asList(pc));
        if (isFixPageCriteria() || config_FixPageCriteria) {
          i.remove();
          LOG.warn("String_Node_Str" + key + "String_Node_Str"+ target+ "String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void checkPageCriteria(final ICS ics,final String target){
  final FTValList o=getList();
  if (o instanceof Map) {
    String[] pc=ics.pageCriteriaKeys(target);
    if (pc == null) {
      pc=new String[0];
    }
    final Map<String,?> m=o;
    for (final Iterator<?> i=m.entrySet().iterator(); i.hasNext(); ) {
      final Entry<String,?> e=(Entry<String,?>)i.next();
      final String key=e.getKey();
      boolean found=!key.startsWith(ARGS);
      if (!found)       found=CALLTEMPLATE_EXCLUDE_VARS.contains(key);
      if (!found) {
        for (        final String c : pc) {
          if ((ARGS + c).equalsIgnoreCase(key)) {
            found=true;
            break;
          }
        }
      }
      if (!found) {
        LOG.error("String_Node_Str" + key + "String_Node_Str"+ target+ "String_Node_Str"+ ics.ResolveVariables("String_Node_Str")+ "String_Node_Str"+ m.keySet().toString()+ "String_Node_Str"+ Arrays.asList(pc));
        if (isFixPageCriteria() || config_FixPageCriteria) {
          i.remove();
          LOG.warn("String_Node_Str" + key + "String_Node_Str"+ target+ "String_Node_Str");
        }
      }
    }
  }
}
Program: 86994
Project: 86994
Buggy source:
UrlRegistry(ICS ics){
  this.ics=ics;
  wraDao=new WraCoreFieldDao();
  vwDao=new VirtualWebrootDao(ics);
}

Fixed version (ground truth):
public UrlRegistry(ICS ics){
  this.ics=ics;
  wraDao=new WraCoreFieldDao();
  vwDao=new VirtualWebrootDao(ics);
}
Program: 86995
Project: 86995
Buggy source:
public AssetIdWithSite resolveAsset(final String virtual_webroot,final String url_path){
  final StatementParam param=REGISTRY_SELECT.newParam();
  param.setString(0,virtual_webroot);
  param.setString(1,url_path);
  final Date now=new Date();
  for (  final Row asset : SqlHelper.select(ics,REGISTRY_SELECT,param)) {
    final String assettype=asset.getString("String_Node_Str");
    final String assetid=asset.getString("String_Node_Str");
    if (inRange(asset,now)) {
      return new AssetIdWithSite(assettype,Long.parseLong(assetid),asset.getString("String_Node_Str"));
    }
  }
  return null;
}

Fixed version (ground truth):
public AssetIdWithSite resolveAsset(final String virtual_webroot,final String url_path){
  final StatementParam param=REGISTRY_SELECT.newParam();
  param.setString(0,virtual_webroot);
  param.setString(1,url_path);
  final Date now=new Date();
  for (  final Row asset : SqlHelper.select(ics,REGISTRY_SELECT,param)) {
    final String assettype=asset.getString("String_Node_Str");
    final String assetid=asset.getString("String_Node_Str");
    if (FilterAssetsByDate.isDateWithinRange(asset.getString("String_Node_Str"),now,asset.getString("String_Node_Str"))) {
      return new AssetIdWithSite(assettype,Long.parseLong(assetid),asset.getString("String_Node_Str"));
    }
  }
  return null;
}
Program: 86998
Project: 86998
Buggy source:
public static boolean isValidOnDate(AssetId id,Date date){
  AssetData d=AssetDataUtils.getAssetData(id,STARTDATE,ENDDATE);
  String sStartdate=d.getAttributeData(STARTDATE) != null && d.getAttributeData(STARTDATE).getData() != null ? d.getAttributeData(STARTDATE).getData().toString() : null;
  Date startDate=goodString(sStartdate) ? Util.parseJdbcDate(sStartdate) : null;
  String sEnddate=d.getAttributeData(ENDDATE) != null && d.getAttributeData(ENDDATE).getData() != null ? d.getAttributeData(ENDDATE).getData().toString() : null;
  Date endDate=goodString(sEnddate) ? Util.parseJdbcDate(sEnddate) : null;
  if (startDate == null && endDate == null) {
    return true;
  }
 else {
    Date effectiveDate=date == null ? new Date() : date;
    if (startDate == null) {
      return effectiveDate.before(endDate);
    }
 else     if (endDate == null) {
      return startDate.before(effectiveDate);
    }
 else {
      return startDate.before(effectiveDate) && effectiveDate.before(endDate);
    }
  }
}

Fixed version (ground truth):
public static boolean isValidOnDate(AssetId id,Date date){
  AssetData d=AssetDataUtils.getAssetData(id,STARTDATE,ENDDATE);
  Date startDate=d.getAttributeData(STARTDATE) != null && d.getAttributeData(STARTDATE).getData() != null ? (Date)d.getAttributeData(STARTDATE).getData() : null;
  Date endDate=d.getAttributeData(ENDDATE) != null && d.getAttributeData(ENDDATE).getData() != null ? (Date)d.getAttributeData(ENDDATE).getData() : null;
  if (startDate == null && endDate == null) {
    return true;
  }
 else {
    Date effectiveDate=date == null ? new Date() : date;
    if (startDate == null) {
      return effectiveDate.before(endDate);
    }
 else     if (endDate == null) {
      return startDate.before(effectiveDate);
    }
 else {
      return startDate.before(effectiveDate) && effectiveDate.before(endDate);
    }
  }
}
Program: 86999
Project: 86999
Buggy source:
@Override protected void doExecute(){
  recordCompositionalDependencies();
  final AssetIdWithSite id=resolveAssetId();
  if (id == null) {
    throw new CSRuntimeException("String_Node_Str",404);
  }
  final String templatename=lookupTemplateForAsset(id);
  if (templatename == null) {
    throw new CSRuntimeException("String_Node_Str",404);
  }
  String site=id.getSite();
  if (site == null) {
    throw new CSRuntimeException("String_Node_Str" + id,404);
  }
  callTemplate(site,id,templatename);
}

Fixed version (ground truth):
@Override protected void doExecute(){
  recordCompositionalDependencies();
  final AssetIdWithSite id=resolveAssetId();
  if (id == null) {
    throw new CSRuntimeException("String_Node_Str",404);
  }
  final String templatename=lookupTemplateForAsset(id);
  if (templatename == null) {
    throw new CSRuntimeException("String_Node_Str",404);
  }
  String site=id.getSite();
  if (site == null) {
    throw new CSRuntimeException("String_Node_Str" + id,404);
  }
  ics.SetVar("String_Node_Str",site);
  callTemplate(site,id,templatename);
}
Program: 87001
Project: 87001
Buggy source:
@Override public void onJoin(InetAddress endpoint,EndPointState epState){
  ApplicationState stateDC=epState.getApplicationState(APPSTATE_DC);
  ApplicationState stateRack=epState.getApplicationState(APPSTATE_RACK);
  String[] location=new String[2];
  location[0]=getDatacenter(endpoint);
  location[1]=getRack(endpoint);
  if (stateDC != null)   location[0]=stateDC.getValue();
  if (stateRack != null)   location[1]=stateRack.getValue();
  if (location[0] == null || location[1] == null) {
    logger.error("String_Node_Str" + endpoint + "String_Node_Str");
    blockFromJoin(endpoint,epState);
    return;
  }
  if (DatabaseDescriptor.getAllowedLocations() != null && !DatabaseDescriptor.getAllowedLocations().contains(location[0] + "String_Node_Str" + location[1])) {
    logger.error("String_Node_Str" + endpoint + "String_Node_Str"+ location[0]+ "String_Node_Str"+ location[1]+ "String_Node_Str");
    blockFromJoin(endpoint,epState);
    return;
  }
  putEndpoints(Collections.singletonMap(endpoint,location));
}

Fixed version (ground truth):
@Override public void onJoin(InetAddress endpoint,EndPointState epState){
  ApplicationState stateDC=epState.getApplicationState(APPSTATE_DC);
  ApplicationState stateRack=epState.getApplicationState(APPSTATE_RACK);
  String[] location=new String[2];
  if (stateDC != null)   location[0]=stateDC.getValue();
  if (stateRack != null)   location[1]=stateRack.getValue();
  if (location[0] == null || location[1] == null) {
    location[0]=getDatacenter(endpoint);
    location[1]=getRack(endpoint);
  }
  if (location[0] == null || location[1] == null) {
    logger.error("String_Node_Str" + endpoint + "String_Node_Str");
    blockFromJoin(endpoint,epState);
    return;
  }
  if (DatabaseDescriptor.getAllowedLocations() != null && !DatabaseDescriptor.getAllowedLocations().contains(location[0] + "String_Node_Str" + location[1])) {
    logger.error("String_Node_Str" + endpoint + "String_Node_Str"+ location[0]+ "String_Node_Str"+ location[1]+ "String_Node_Str");
    blockFromJoin(endpoint,epState);
    return;
  }
  putEndpoints(Collections.singletonMap(endpoint,location));
}
Program: 87002
Project: 87002
Buggy source:
/** 
 * @param token either 111.222.333.444 or token string value
 * @return
 */
private InetAddress tokenToEndpoint(String token){
  if (token.matches("String_Node_Str")) {
    try {
      InetAddress ip=InetAddress.getByName(token);
      return ip;
    }
 catch (    UnknownHostException e) {
    }
  }
  Token<?> hintToken=StorageService.getPartitioner().getTokenFactory().fromString(token);
  InetAddress endPoint=StorageService.instance.getTokenMetadata().getEndPoint(hintToken);
  return endPoint;
}

Fixed version (ground truth):
/** 
 * @param token either 111.222.333.444 or token string value
 * @return
 */
private InetAddress tokenToEndpoint(String token){
  if (token.matches("String_Node_Str")) {
    try {
      InetAddress ip=InetAddress.getByName(token);
      return ip;
    }
 catch (    UnknownHostException e) {
    }
  }
  Token<?> hintToken=StorageService.getPartitioner().getTokenFactory().fromString(token);
  InetAddress endPoint=StorageService.instance.getTokenMetadata().getEndPointHint(hintToken);
  return endPoint;
}
Program: 87003
Project: 87003
Buggy source:
private void sync(){
  Collection<Deque<HintLogSegment>> values=segments.values();
  for (  Deque<HintLogSegment> deque : values) {
    HintLogSegment last=deque.peekLast();
    if (last != null)     try {
      last.sync();
      if (last.length() >= SEGMENT_SIZE) {
        last.close();
        getEndpointSegments(last.getToken()).add(new HintLogSegment(last.getToken()));
      }
      if ((deque.size() > 1 || !last.isEmpty()) && HINT_DELIVERY_ON_SYNC) {
        InetAddress endp=tokenToEndpoint(last.getToken());
        if (FailureDetector.instance.isAlive(endp)) {
          HintedHandOffManager.instance().deliverHints(endp);
        }
 else         if (endp == null || !Gossiper.instance.isKnownEndpoint(endp)) {
          logger.info("String_Node_Str" + last.getToken() + "String_Node_Str");
          for (          HintLogSegment hintLogSegment : deque) {
            hintLogSegment.close();
            hintLogSegment.delete();
          }
          deque.clear();
          deque.add(new HintLogSegment(last.getToken()));
        }
      }
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + last,e);
    }
  }
}

Fixed version (ground truth):
private void sync(){
  Collection<Deque<HintLogSegment>> values=segments.values();
  for (  Deque<HintLogSegment> deque : values) {
    HintLogSegment last=deque.peekLast();
    if (last != null)     try {
      last.sync();
      if (last.length() >= SEGMENT_SIZE) {
        last.close();
        getEndpointSegments(last.getToken()).add(new HintLogSegment(last.getToken()));
      }
      if ((deque.size() > 1 || !last.isEmpty()) && HINT_DELIVERY_ON_SYNC) {
        InetAddress endp=tokenToEndpoint(last.getToken());
        if (endp != null && FailureDetector.instance.isAlive(endp)) {
          HintedHandOffManager.instance().deliverHints(endp);
        }
 else         if (endp == null || !Gossiper.instance.isKnownEndpoint(endp)) {
          logger.info("String_Node_Str" + last.getToken() + "String_Node_Str");
          for (          HintLogSegment hintLogSegment : deque) {
            hintLogSegment.close();
            hintLogSegment.delete();
          }
          deque.clear();
          deque.add(new HintLogSegment(last.getToken()));
        }
      }
    }
 catch (    IOException e) {
      logger.error("String_Node_Str" + last,e);
    }
  }
}
Program: 87004
Project: 87004
Buggy source:
private String endpointToToken(InetAddress endpoint){
  Token<?> token=StorageService.instance.getTokenMetadata().getToken(endpoint);
  return StorageService.instance.getPartitioner().getTokenFactory().toString(token);
}

Fixed version (ground truth):
private String endpointToToken(InetAddress endpoint){
  Token<?> token=StorageService.instance.getTokenMetadata().getTokenHint(endpoint);
  return StorageService.instance.getPartitioner().getTokenFactory().toString(token);
}
Program: 87006
Project: 87006
Buggy source:
protected ArrayList<InetAddress> doCalculateEndpoints(Token keyToken,TokenMetadata metadata,String table){
  int replicas=DatabaseDescriptor.getReplicationFactor(table);
  ArrayList<InetAddress> endpoints=new ArrayList<InetAddress>(replicas);
  do {
    List<Token> tokens=getReplicaTokens(keyToken,metadata,endpoints.size());
    if (tokens.isEmpty())     return endpoints;
    String keyTokenString=keyToken.toString();
    int domain=Integer.parseInt(keyTokenString.substring(0,2),16) & 0xFF;
    Iterator<Token> iter=TokenMetadata.ringIterator(tokens,keyToken,false);
    do {
      InetAddress endPoint=metadata.getEndPoint(iter.next());
      if (endpoints.contains(endPoint))       endpoints.add(metadata.getEndPoint(iter.next()));
 else       endpoints.add(endPoint);
    }
 while (endpoints.size() < replicas && domain == shuffle(domain));
    domain=shuffle(domain);
    keyToken=odklPartitioner.toStringToken(domain,keyTokenString);
  }
 while (endpoints.size() < replicas);
  return endpoints;
}

Fixed version (ground truth):
protected ArrayList<InetAddress> doCalculateEndpoints(Token keyToken,TokenMetadata metadata,String table){
  int replicas=DatabaseDescriptor.getReplicationFactor(table);
  ArrayList<InetAddress> endpoints=new ArrayList<InetAddress>(replicas);
  do {
    List<Token> tokens=getReplicaTokens(keyToken,metadata,endpoints.size());
    if (tokens.isEmpty())     return endpoints;
    String keyTokenString=keyToken.toString();
    int domain=keyTokenDomain(keyTokenString);
    Iterator<Token> iter=TokenMetadata.ringIterator(tokens,keyToken,false);
    do {
      InetAddress endPoint=metadata.getEndPoint(iter.next());
      if (endpoints.contains(endPoint))       endpoints.add(metadata.getEndPoint(iter.next()));
 else       endpoints.add(endPoint);
    }
 while (endpoints.size() < replicas && domain == shuffle(domain));
    domain=shuffle(domain);
    keyToken=odklPartitioner.toStringToken(domain,keyTokenString);
  }
 while (endpoints.size() < replicas);
  return endpoints;
}