Program: 93621
Project: 93621
Buggy source:
/** 
 * return the closest EObject of the passed one found in the sideToFind storage.
 * @param inProgress the comparison under match.
 * @param eObj the base EObject.
 * @param originalSide the side of the base EObject.
 * @param sideToFind the side to search in.
 * @param shouldDoubleCheck true if we should make sure that the found EObject has the inverse relationship with the base one.
 * @return the closest EObject of the passed one found in the sideToFind storage.
 */
private EObject findTheClosest(Comparison inProgress,final EObject eObj,final Side originalSide,final Side sideToFind,boolean shouldDoubleCheck){
  List<EObject> storageToSearchFor=lefts;
switch (sideToFind) {
case RIGHT:
    storageToSearchFor=rights;
  break;
case LEFT:
storageToSearchFor=lefts;
break;
case ORIGIN:
storageToSearchFor=origins;
break;
default :
break;
}
Candidate best=findIdenticMatch(inProgress,eObj,storageToSearchFor);
if (best.some()) {
return best.eObject;
}
SortedMap<Double,EObject> candidates=Maps.newTreeMap();
Iterator<EObject> it=storageToSearchFor.iterator();
while (best.distance != 0 && it.hasNext()) {
EObject potentialClosest=it.next();
double dist=meter.distance(inProgress,eObj,potentialClosest);
stats.similarityCompare();
if (dist < best.distance) {
if (shouldDoubleCheck) {
candidates.put(Double.valueOf(dist),potentialClosest);
}
 else {
best.distance=dist;
best.eObject=potentialClosest;
}
}
}
if (shouldDoubleCheck) {
for (Entry<Double,EObject> entry : candidates.entrySet()) {
EObject doubleCheck=findTheClosest(inProgress,entry.getValue(),sideToFind,originalSide,false);
stats.doubleCheck();
if (doubleCheck == eObj) {
stats.similaritySuccess();
best.eObject=entry.getValue();
best.distance=Double.valueOf(entry.getKey());
break;
}
 else {
stats.failedDoubleCheck();
}
}
}
if (!best.some()) {
stats.noMatch();
}
return best.eObject;
}

Fixed version (ground truth):
/** 
 * return the closest EObject of the passed one found in the sideToFind storage.
 * @param inProgress the comparison under match.
 * @param eObj the base EObject.
 * @param originalSide the side of the base EObject.
 * @param sideToFind the side to search in.
 * @param shouldDoubleCheck true if we should make sure that the found EObject has the inverse relationship with the base one.
 * @return the closest EObject of the passed one found in the sideToFind storage.
 */
private EObject findTheClosest(Comparison inProgress,final EObject eObj,final Side originalSide,final Side sideToFind,boolean shouldDoubleCheck){
  List<EObject> storageToSearchFor=lefts;
switch (sideToFind) {
case RIGHT:
    storageToSearchFor=rights;
  break;
case LEFT:
storageToSearchFor=lefts;
break;
case ORIGIN:
storageToSearchFor=origins;
break;
default :
break;
}
Candidate best=findIdenticMatch(inProgress,eObj,storageToSearchFor);
if (best.some()) {
return best.eObject;
}
SortedMap<Double,EObject> candidates=Maps.newTreeMap();
Iterator<EObject> it=storageToSearchFor.iterator();
while (best.distance != 0 && it.hasNext()) {
EObject potentialClosest=it.next();
double dist=meter.distance(inProgress,eObj,potentialClosest);
stats.similarityCompare();
if (dist < best.distance) {
if (shouldDoubleCheck) {
candidates.put(Double.valueOf(dist),potentialClosest);
}
 else {
best.distance=dist;
best.eObject=potentialClosest;
}
}
}
if (shouldDoubleCheck) {
for (Entry<Double,EObject> entry : candidates.entrySet()) {
EObject doubleCheck=findTheClosest(inProgress,entry.getValue(),sideToFind,originalSide,false);
stats.doubleCheck();
if (doubleCheck == eObj) {
stats.similaritySuccess();
best.eObject=entry.getValue();
best.distance=entry.getKey().doubleValue();
break;
}
 else {
stats.failedDoubleCheck();
}
}
}
if (!best.some()) {
stats.noMatch();
}
return best.eObject;
}