Program: 52940
Project: 52940
Buggy source:
@Override public TIntSet getNeighboringItemIds(Geometry g,String refSysName,Set<String> subLayers,double minDist,double maxDist) throws DaoException {
  if (subLayers.size() == 0)   throw new DaoException("String_Node_Str");
  FilterFactory2 ff=CommonFactoryFinder.getFilterFactory2();
  PropertyName geomProperty=ff.property(db.getGeometryAttributeName());
  PropertyName refSysProperty=ff.property(db.getRefSysAttributeName());
  Filter refSysFilter=ff.equals(refSysProperty,ff.literal(refSysName));
  PropertyName layerProperty=ff.property(db.getLayerAttributeName());
  List<Filter> layerFilters=Lists.newArrayList();
  for (  String subLayer : subLayers) {
    Filter curLayerFilter=ff.equals(layerProperty,ff.literal(subLayer));
    layerFilters.add(curLayerFilter);
  }
  Filter layerFilter=ff.and(layerFilters);
  Filter withinFilter=ff.dwithin(geomProperty,ff.literal(g),10.0,"String_Node_Str");
  List<Filter> filters=Lists.newArrayList();
  filters.add(refSysFilter);
  filters.add(layerFilter);
  filters.add(withinFilter);
  Filter finalFilter=ff.and(filters);
  try {
    FeatureSource featureSource=db.getFeatureSource();
    FeatureCollection containedFeatures=featureSource.getFeatures(finalFilter);
    FeatureIterator featureIterator=containedFeatures.features();
    TIntSet rVal=new TIntHashSet();
    while (featureIterator.hasNext()) {
      Feature f=featureIterator.next();
      Integer itemId=(Integer)f.getProperty(db.getItemIdAttributeName()).getValue();
      rVal.add(itemId);
    }
    return rVal;
  }
 catch (  IOException e) {
    throw new DaoException(e);
  }
}

Fixed version (ground truth):
@Override public TIntSet getNeighboringItemIds(Geometry g,String refSysName,Set<String> subLayers,double minDist,double maxDist) throws DaoException {
  if (subLayers.size() == 0)   throw new DaoException("String_Node_Str");
  FilterFactory2 ff=CommonFactoryFinder.getFilterFactory2();
  PropertyName geomProperty=ff.property(db.getGeometryAttributeName());
  PropertyName refSysProperty=ff.property(db.getRefSysAttributeName());
  Filter refSysFilter=ff.equals(refSysProperty,ff.literal(refSysName));
  PropertyName layerProperty=ff.property(db.getLayerAttributeName());
  List<Filter> layerFilters=Lists.newArrayList();
  for (  String subLayer : subLayers) {
    Filter curLayerFilter=ff.equals(layerProperty,ff.literal(subLayer));
    layerFilters.add(curLayerFilter);
  }
  Filter layerFilter=ff.and(layerFilters);
  Filter withinFilter=ff.dwithin(geomProperty,ff.literal(g),maxDist / 111.1949266,"String_Node_Str");
  Filter beyondFilter=ff.beyond(geomProperty,ff.literal(g),minDist / 111.1949266,"String_Node_Str");
  List<Filter> filters=Lists.newArrayList();
  filters.add(refSysFilter);
  filters.add(layerFilter);
  filters.add(withinFilter);
  filters.add(beyondFilter);
  Filter finalFilter=ff.and(filters);
  try {
    FeatureSource featureSource=db.getFeatureSource();
    FeatureCollection containedFeatures=featureSource.getFeatures(finalFilter);
    FeatureIterator featureIterator=containedFeatures.features();
    TIntSet rVal=new TIntHashSet();
    while (featureIterator.hasNext()) {
      Feature f=featureIterator.next();
      Integer itemId=(Integer)f.getProperty(db.getItemIdAttributeName()).getValue();
      rVal.add(itemId);
    }
    return rVal;
  }
 catch (  IOException e) {
    throw new DaoException(e);
  }
}