Program: 31716
Project: 31716
Buggy source:
/** 
 * Invoked when the mapper wishes to mark a set of incoming relationships like (a)<-[:T]-(*) as deleted, prior to possibly re-establishing them individually as it traverses the entity graph. There are two reasons why a set of relationships might not be be able to be marked deleted: 1) the request to mark them as deleted has already been made 2) the relationship is not persisted in the graph (i.e. its a new relationship) Only case 1) is considered to be a failed request, because this context is only concerned about pre-existing relationships in the graph. In order to distinguish between the two cases, we also maintain a list of successfully deleted relationships, so that uf we try to delete an already-deleted set of relationships we can signal the error.
 * @param tgt the identity of the node at the pointy end of the relationship
 * @param relationshipType the type of the relationship
 * @return true if the relationship was deleted or doesn't exist in the graph, false otherwise
 */
public boolean deregisterIncomingRelationships(Long tgt,String relationshipType){
  Iterator<MappedRelationship> iterator=registeredRelationships.iterator();
  boolean found=false;
  while (iterator.hasNext()) {
    MappedRelationship mappedRelationship=iterator.next();
    if (mappedRelationship.getEndNodeId() == tgt && mappedRelationship.getRelationshipType().equals(relationshipType)) {
      iterator.remove();
      deletedRelationships.add(mappedRelationship);
      found=true;
    }
  }
  if (found)   return true;
  iterator=deletedRelationships.iterator();
  while (iterator.hasNext()) {
    MappedRelationship mappedRelationship=iterator.next();
    if (mappedRelationship.getEndNodeId() == tgt && mappedRelationship.getRelationshipType().equals(relationshipType)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Invoked when the mapper wishes to mark a set of incoming relationships like (a)&lt;-[:T]-(*) as deleted, prior to possibly re-establishing them individually as it traverses the entity graph. There are two reasons why a set of relationships might not be be able to be marked deleted: 1) the request to mark them as deleted has already been made 2) the relationship is not persisted in the graph (i.e. its a new relationship) Only case 1) is considered to be a failed request, because this context is only concerned about pre-existing relationships in the graph. In order to distinguish between the two cases, we also maintain a list of successfully deleted relationships, so that uf we try to delete an already-deleted set of relationships we can signal the error.
 * @param tgt the identity of the node at the pointy end of the relationship
 * @param relationshipType the type of the relationship
 * @return true if the relationship was deleted or doesn't exist in the graph, false otherwise
 */
public boolean deregisterIncomingRelationships(Long tgt,String relationshipType){
  Iterator<MappedRelationship> iterator=registeredRelationships.iterator();
  boolean found=false;
  while (iterator.hasNext()) {
    MappedRelationship mappedRelationship=iterator.next();
    if (mappedRelationship.getEndNodeId() == tgt && mappedRelationship.getRelationshipType().equals(relationshipType)) {
      iterator.remove();
      deletedRelationships.add(mappedRelationship);
      found=true;
    }
  }
  if (found)   return true;
  iterator=deletedRelationships.iterator();
  while (iterator.hasNext()) {
    MappedRelationship mappedRelationship=iterator.next();
    if (mappedRelationship.getEndNodeId() == tgt && mappedRelationship.getRelationshipType().equals(relationshipType)) {
      return false;
    }
  }
  return true;
}