Program: 155277
Project: 155277
Buggy source:
private void disconnectRelationship(RelationshipRecord rel) throws IOException {
  if (rel.getFirstPrevRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getFirstPrevRel());
    lockManager.getWriteLock(lockableRel);
    RelationshipRecord prevRel=getRelationshipRecord(rel.getFirstPrevRel());
    if (prevRel == null) {
      prevRel=getRelationshipStore().getRecord(rel.getFirstPrevRel(),readFromBuffer);
      addRelationshipRecord(prevRel);
    }
    if (prevRel.getFirstNode() == rel.getFirstNode()) {
      prevRel.setFirstNextRel(rel.getFirstNextRel());
    }
 else     if (prevRel.getSecondNode() == rel.getFirstNode()) {
      prevRel.setSecondNextRel(rel.getFirstNextRel());
    }
 else {
      throw new RuntimeException(prevRel + "String_Node_Str" + rel);
    }
    addRelationshipLockToTransaction(lockableRel);
  }
  if (rel.getFirstNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getFirstNextRel());
    lockManager.getWriteLock(lockableRel);
    RelationshipRecord nextRel=getRelationshipRecord(rel.getFirstNextRel());
    if (nextRel == null) {
      nextRel=getRelationshipStore().getRecord(rel.getFirstNextRel(),readFromBuffer);
      addRelationshipRecord(nextRel);
    }
    if (nextRel.getFirstNode() == rel.getFirstNode()) {
      nextRel.setFirstPrevRel(rel.getFirstPrevRel());
    }
 else     if (nextRel.getSecondNode() == rel.getFirstNode()) {
      nextRel.setSecondPrevRel(rel.getFirstPrevRel());
    }
 else {
      throw new RuntimeException(nextRel + "String_Node_Str" + rel);
    }
    addRelationshipLockToTransaction(lockableRel);
  }
  if (rel.getSecondPrevRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getSecondPrevRel());
    lockManager.getWriteLock(lockableRel);
    RelationshipRecord prevRel=getRelationshipRecord(rel.getSecondPrevRel());
    if (prevRel == null) {
      prevRel=getRelationshipStore().getRecord(rel.getSecondPrevRel(),readFromBuffer);
      addRelationshipRecord(prevRel);
    }
    if (prevRel.getFirstNode() == rel.getSecondNode()) {
      prevRel.setFirstNextRel(rel.getSecondNextRel());
    }
 else     if (prevRel.getSecondNode() == rel.getSecondNode()) {
      prevRel.setSecondNextRel(rel.getSecondNextRel());
    }
 else {
      throw new RuntimeException(prevRel + "String_Node_Str" + rel);
    }
    addRelationshipLockToTransaction(lockableRel);
  }
  if (rel.getSecondNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getSecondNextRel());
    lockManager.getWriteLock(lockableRel);
    RelationshipRecord nextRel=getRelationshipRecord(rel.getSecondNextRel());
    if (nextRel == null) {
      nextRel=getRelationshipStore().getRecord(rel.getSecondNextRel(),readFromBuffer);
      addRelationshipRecord(nextRel);
    }
    if (nextRel.getFirstNode() == rel.getSecondNode()) {
      nextRel.setFirstPrevRel(rel.getSecondPrevRel());
    }
 else     if (nextRel.getSecondNode() == rel.getSecondNode()) {
      nextRel.setSecondPrevRel(rel.getSecondPrevRel());
    }
 else {
      throw new RuntimeException(nextRel + "String_Node_Str" + rel);
    }
    addRelationshipLockToTransaction(lockableRel);
  }
}

Fixed version (ground truth):
private void disconnectRelationship(RelationshipRecord rel) throws IOException {
  if (rel.getFirstPrevRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getFirstPrevRel());
    getWriteLock(lockableRel);
    RelationshipRecord prevRel=getRelationshipRecord(rel.getFirstPrevRel());
    if (prevRel == null) {
      prevRel=getRelationshipStore().getRecord(rel.getFirstPrevRel(),readFromBuffer);
      addRelationshipRecord(prevRel);
    }
    if (prevRel.getFirstNode() == rel.getFirstNode()) {
      prevRel.setFirstNextRel(rel.getFirstNextRel());
    }
 else     if (prevRel.getSecondNode() == rel.getFirstNode()) {
      prevRel.setSecondNextRel(rel.getFirstNextRel());
    }
 else {
      throw new RuntimeException(prevRel + "String_Node_Str" + rel);
    }
  }
  if (rel.getFirstNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getFirstNextRel());
    getWriteLock(lockableRel);
    RelationshipRecord nextRel=getRelationshipRecord(rel.getFirstNextRel());
    if (nextRel == null) {
      nextRel=getRelationshipStore().getRecord(rel.getFirstNextRel(),readFromBuffer);
      addRelationshipRecord(nextRel);
    }
    if (nextRel.getFirstNode() == rel.getFirstNode()) {
      nextRel.setFirstPrevRel(rel.getFirstPrevRel());
    }
 else     if (nextRel.getSecondNode() == rel.getFirstNode()) {
      nextRel.setSecondPrevRel(rel.getFirstPrevRel());
    }
 else {
      throw new RuntimeException(nextRel + "String_Node_Str" + rel);
    }
  }
  if (rel.getSecondPrevRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getSecondPrevRel());
    getWriteLock(lockableRel);
    RelationshipRecord prevRel=getRelationshipRecord(rel.getSecondPrevRel());
    if (prevRel == null) {
      prevRel=getRelationshipStore().getRecord(rel.getSecondPrevRel(),readFromBuffer);
      addRelationshipRecord(prevRel);
    }
    if (prevRel.getFirstNode() == rel.getSecondNode()) {
      prevRel.setFirstNextRel(rel.getSecondNextRel());
    }
 else     if (prevRel.getSecondNode() == rel.getSecondNode()) {
      prevRel.setSecondNextRel(rel.getSecondNextRel());
    }
 else {
      throw new RuntimeException(prevRel + "String_Node_Str" + rel);
    }
  }
  if (rel.getSecondNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
    Relationship lockableRel=new LockableRelationship(rel.getSecondNextRel());
    getWriteLock(lockableRel);
    RelationshipRecord nextRel=getRelationshipRecord(rel.getSecondNextRel());
    if (nextRel == null) {
      nextRel=getRelationshipStore().getRecord(rel.getSecondNextRel(),readFromBuffer);
      addRelationshipRecord(nextRel);
    }
    if (nextRel.getFirstNode() == rel.getSecondNode()) {
      nextRel.setFirstPrevRel(rel.getSecondPrevRel());
    }
 else     if (nextRel.getSecondNode() == rel.getSecondNode()) {
      nextRel.setSecondPrevRel(rel.getSecondPrevRel());
    }
 else {
      throw new RuntimeException(nextRel + "String_Node_Str" + rel);
    }
  }
}