nus-yam/ex-repair huggingface dataset:
Program: 154971
Project: 154971
Buggy source:
private boolean sendLog(){
  if (retries > 20) {
    close();
  }
  connection.write();
  log("String_Node_Str" + logVersionToSend);
  if (!buffer.hasRemaining()) {
    buffer.clear();
    try {
      if (logToSend.read(buffer) <= 0) {
        releaseWriteBuffer();
        if (nextLogVersion != -1) {
          logToSend=master.getLog(xaDsName,nextLogVersion);
          logLength=master.getLogLength(xaDsName,nextLogVersion);
          logVersionToSend=nextLogVersion;
          nextLogVersion=-1;
          setStatus(Status.SETUP_OFFER_LOG);
        }
 else {
          setStatus(Status.GET_MESSAGE);
        }
        logLength=-1;
        logVersionToSend=-1;
        logToSend=null;
        return true;
      }
      buffer.flip();
    }
 catch (    IOException e) {
      log("String_Node_Str",e);
      close();
      return true;
    }
  }
  retries++;
  return false;
}

Fixed version (ground truth):
private boolean sendLog(){
  if (retries > 20) {
    close();
  }
  connection.write();
  log("String_Node_Str" + logVersionToSend);
  if (!buffer.hasRemaining()) {
    buffer.clear();
    try {
      if (logToSend.read(buffer) <= 0) {
        releaseWriteBuffer();
        logToSend.close();
        if (nextLogVersion != -1) {
          logToSend=master.getLog(xaDsName,nextLogVersion);
          logLength=master.getLogLength(xaDsName,nextLogVersion);
          logVersionToSend=nextLogVersion;
          nextLogVersion=-1;
          setStatus(Status.SETUP_OFFER_LOG);
        }
 else {
          setStatus(Status.GET_MESSAGE);
        }
        logLength=-1;
        logVersionToSend=-1;
        logToSend=null;
        return true;
      }
      buffer.flip();
    }
 catch (    IOException e) {
      log("String_Node_Str",e);
      close();
      return true;
    }
  }
  retries++;
  return false;
}
Program: 154972
Project: 154972
Buggy source:
public Iterable<Relationship> expand(final Node start){
  if (types.length == 0) {
    return start.getRelationships();
  }
  if (types.length == 1) {
    RelationshipType type=types[0];
    return start.getRelationships(type,directions.get(type));
  }
  return new FilteringIterable<Relationship>(start.getRelationships(types)){
    @Override protected boolean passes(    Relationship item){
switch (directions.get(item.getType())) {
case INCOMING:
        return item.getEndNode().equals(start);
case OUTGOING:
      return item.getStartNode().equals(start);
default :
    return true;
}
}
}
;
}

Fixed version (ground truth):
public Iterable<Relationship> expand(final Node start){
  if (types.length == 0) {
    return start.getRelationships();
  }
  if (types.length == 1) {
    RelationshipType type=types[0];
    return start.getRelationships(type,directions.get(type.name()));
  }
  return new FilteringIterable<Relationship>(start.getRelationships(types)){
    @Override protected boolean passes(    Relationship item){
switch (directions.get(item.getType().name())) {
case INCOMING:
        return item.getEndNode().equals(start);
case OUTGOING:
      return item.getStartNode().equals(start);
default :
    return true;
}
}
}
;
}
Program: 154973
Project: 154973
Buggy source:
@Override protected boolean passes(Relationship item){
switch (directions.get(item.getType())) {
case INCOMING:
    return item.getEndNode().equals(start);
case OUTGOING:
  return item.getStartNode().equals(start);
default :
return true;
}
}

Fixed version (ground truth):
@Override protected boolean passes(Relationship item){
switch (directions.get(item.getType().name())) {
case INCOMING:
    return item.getEndNode().equals(start);
case OUTGOING:
  return item.getStartNode().equals(start);
default :
return true;
}
}
Program: 154974
Project: 154974
Buggy source:
private RelationshipExpander(RelationshipType[] types,Direction[] dirs){
  if (types.length != dirs.length) {
    throw new IllegalArgumentException();
  }
  this.types=new RelationshipType[types.length];
  this.directions=new HashMap<RelationshipType,Direction>();
  for (int i=0; i < types.length; i++) {
    this.types[i]=types[i];
    this.directions.put(types[i],dirs[i]);
  }
}

Fixed version (ground truth):
private RelationshipExpander(RelationshipType[] types,Direction[] dirs){
  if (types.length != dirs.length) {
    throw new IllegalArgumentException();
  }
  this.types=new RelationshipType[types.length];
  this.directions=new HashMap<String,Direction>();
  for (int i=0; i < types.length; i++) {
    this.types[i]=types[i];
    this.directions.put(types[i].name(),dirs[i]);
  }
}
Program: 154975
Project: 154975
Buggy source:
public ArrayMap<Integer,PropertyData> getCowPropertyRemoveMap(Primitive primitive,boolean create){
  if (!create) {
    return getCowPropertyRemoveMap(primitive);
  }
  PrimitiveElement primitiveElement=getAndSetupPrimitiveElement();
  if (primitive instanceof NodeImpl) {
    ArrayMap<Integer,CowNodeElement> cowElements=primitiveElement.nodes;
    CowNodeElement element=cowElements.get(primitive.id);
    if (element == null) {
      element=new CowNodeElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyRemoveMap == null) {
      element.propertyRemoveMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyRemoveMap;
  }
 else   if (primitive instanceof RelationshipImpl) {
    ArrayMap<Integer,CowRelElement> cowElements=primitiveElement.relationships;
    CowRelElement element=cowElements.get(primitive.id);
    if (element == null) {
      element=new CowRelElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyRemoveMap == null) {
      element.propertyRemoveMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyRemoveMap;
  }
  return null;
}

Fixed version (ground truth):
public ArrayMap<Integer,PropertyData> getCowPropertyRemoveMap(Primitive primitive,boolean create){
  if (!create) {
    return getCowPropertyRemoveMap(primitive);
  }
  PrimitiveElement primitiveElement=getAndSetupPrimitiveElement();
  if (primitive instanceof NodeImpl) {
    ArrayMap<Integer,CowNodeElement> cowElements=primitiveElement.nodes;
    CowNodeElement element=cowElements.get(primitive.id);
    if (element != null && element.deleted) {
      throw new IllegalStateException("String_Node_Str" + primitive.id + "String_Node_Str");
    }
    if (element == null) {
      element=new CowNodeElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyRemoveMap == null) {
      element.propertyRemoveMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyRemoveMap;
  }
 else   if (primitive instanceof RelationshipImpl) {
    ArrayMap<Integer,CowRelElement> cowElements=primitiveElement.relationships;
    CowRelElement element=cowElements.get(primitive.id);
    if (element != null && element.deleted) {
      throw new IllegalStateException("String_Node_Str" + primitive.id + "String_Node_Str");
    }
    if (element == null) {
      element=new CowRelElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyRemoveMap == null) {
      element.propertyRemoveMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyRemoveMap;
  }
  return null;
}
Program: 154976
Project: 154976
Buggy source:
public ArrayMap<Integer,PropertyData> getCowPropertyAddMap(Primitive primitive,boolean create){
  if (!create) {
    return getCowPropertyAddMap(primitive);
  }
  PrimitiveElement primitiveElement=getAndSetupPrimitiveElement();
  if (primitive instanceof NodeImpl) {
    ArrayMap<Integer,CowNodeElement> cowElements=primitiveElement.nodes;
    CowNodeElement element=cowElements.get(primitive.id);
    if (element == null) {
      element=new CowNodeElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyAddMap == null) {
      element.propertyAddMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyAddMap;
  }
 else   if (primitive instanceof RelationshipImpl) {
    ArrayMap<Integer,CowRelElement> cowElements=primitiveElement.relationships;
    CowRelElement element=cowElements.get(primitive.id);
    if (element == null) {
      element=new CowRelElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyAddMap == null) {
      element.propertyAddMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyAddMap;
  }
  return null;
}

Fixed version (ground truth):
public ArrayMap<Integer,PropertyData> getCowPropertyAddMap(Primitive primitive,boolean create){
  if (!create) {
    return getCowPropertyAddMap(primitive);
  }
  PrimitiveElement primitiveElement=getAndSetupPrimitiveElement();
  if (primitive instanceof NodeImpl) {
    ArrayMap<Integer,CowNodeElement> cowElements=primitiveElement.nodes;
    CowNodeElement element=cowElements.get(primitive.id);
    if (element != null && element.deleted) {
      throw new IllegalStateException("String_Node_Str" + primitive.id + "String_Node_Str");
    }
    if (element == null) {
      element=new CowNodeElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyAddMap == null) {
      element.propertyAddMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyAddMap;
  }
 else   if (primitive instanceof RelationshipImpl) {
    ArrayMap<Integer,CowRelElement> cowElements=primitiveElement.relationships;
    CowRelElement element=cowElements.get(primitive.id);
    if (element != null && element.deleted) {
      throw new IllegalStateException("String_Node_Str" + primitive.id + "String_Node_Str");
    }
    if (element == null) {
      element=new CowRelElement();
      cowElements.put(primitive.id,element);
    }
    if (element.propertyAddMap == null) {
      element.propertyAddMap=new ArrayMap<Integer,PropertyData>();
    }
    return element.propertyAddMap;
  }
  return null;
}
Program: 154977
Project: 154977
Buggy source:
void deleteNode(NodeImpl node){
  int nodeId=(int)node.getId();
  persistenceManager.nodeDelete(nodeId);
}

Fixed version (ground truth):
void deleteNode(NodeImpl node){
  int nodeId=(int)node.getId();
  deletePrimitive(node);
  persistenceManager.nodeDelete(nodeId);
}
Program: 154978
Project: 154978
Buggy source:
void deleteRelationship(RelationshipImpl rel){
  int relId=(int)rel.getId();
  persistenceManager.relDelete(relId);
}

Fixed version (ground truth):
void deleteRelationship(RelationshipImpl rel){
  int relId=(int)rel.getId();
  deletePrimitive(rel);
  persistenceManager.relDelete(relId);
}
Program: 154979
Project: 154979
Buggy source:
public boolean nodeLoadLight(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord != null) {
    return nodeRecord.inUse();
  }
  return getNodeStore().loadLightNode(nodeId);
}

Fixed version (ground truth):
public boolean nodeLoadLight(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord != null) {
    return true;
  }
  return getNodeStore().loadLightNode(nodeId);
}
Program: 154980
Project: 154980
Buggy source:
public RelationshipData relationshipLoad(int id){
  RelationshipRecord relRecord=getRelationshipRecord(id);
  if (relRecord != null) {
    if (!relRecord.inUse()) {
      return null;
    }
    return new RelationshipData(id,relRecord.getFirstNode(),relRecord.getSecondNode(),relRecord.getType());
  }
  relRecord=getRelationshipStore().getLightRel(id);
  if (relRecord != null) {
    return new RelationshipData(id,relRecord.getFirstNode(),relRecord.getSecondNode(),relRecord.getType());
  }
  return null;
}

Fixed version (ground truth):
public RelationshipData relationshipLoad(int id){
  RelationshipRecord relRecord=getRelationshipRecord(id);
  if (relRecord != null) {
    return new RelationshipData(id,relRecord.getFirstNode(),relRecord.getSecondNode(),relRecord.getType());
  }
  relRecord=getRelationshipStore().getLightRel(id);
  if (relRecord != null) {
    return new RelationshipData(id,relRecord.getFirstNode(),relRecord.getSecondNode(),relRecord.getType());
  }
  return null;
}
Program: 154981
Project: 154981
Buggy source:
public ArrayMap<Integer,PropertyData> relGetProperties(int relId){
  RelationshipRecord relRecord=getRelationshipRecord(relId);
  if (relRecord == null) {
    relRecord=getRelationshipStore().getRecord(relId);
  }
  if (!relRecord.inUse()) {
    throw new InvalidRecordException("String_Node_Str" + relId + "String_Node_Str");
  }
  int nextProp=relRecord.getNextProp();
  ArrayMap<Integer,PropertyData> propertyMap=new ArrayMap<Integer,PropertyData>(9,false,true);
  while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
    PropertyRecord propRecord=getPropertyRecord(nextProp);
    if (propRecord == null) {
      propRecord=getPropertyStore().getLightRecord(nextProp);
    }
    if (!propRecord.isCreated()) {
      propertyMap.put(propRecord.getKeyIndexId(),new PropertyData(propRecord.getId(),propertyGetValueOrNull(propRecord)));
    }
    nextProp=propRecord.getNextProp();
  }
  return propertyMap;
}

Fixed version (ground truth):
public ArrayMap<Integer,PropertyData> relGetProperties(int relId){
  RelationshipRecord relRecord=getRelationshipRecord(relId);
  if (relRecord != null) {
    if (!relRecord.inUse()) {
      throw new IllegalStateException("String_Node_Str" + relId + "String_Node_Str");
    }
  }
 else {
    relRecord=getRelationshipStore().getRecord(relId);
  }
  if (!relRecord.inUse()) {
    throw new InvalidRecordException("String_Node_Str" + relId + "String_Node_Str");
  }
  int nextProp=relRecord.getNextProp();
  ArrayMap<Integer,PropertyData> propertyMap=new ArrayMap<Integer,PropertyData>(9,false,true);
  while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
    PropertyRecord propRecord=getPropertyRecord(nextProp);
    if (propRecord == null) {
      propRecord=getPropertyStore().getLightRecord(nextProp);
    }
    if (!propRecord.isCreated()) {
      propertyMap.put(propRecord.getKeyIndexId(),new PropertyData(propRecord.getId(),propertyGetValueOrNull(propRecord)));
    }
    nextProp=propRecord.getNextProp();
  }
  return propertyMap;
}
Program: 154982
Project: 154982
Buggy source:
public RelationshipChainPosition getRelationshipChainPosition(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord == null) {
    nodeRecord=getNodeStore().getRecord(nodeId);
  }
 else   if (!nodeRecord.inUse()) {
    return new RelationshipChainPosition(Record.NO_NEXT_RELATIONSHIP.intValue());
  }
  int nextRel=nodeRecord.getNextRel();
  return new RelationshipChainPosition(nextRel);
}

Fixed version (ground truth):
public RelationshipChainPosition getRelationshipChainPosition(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord == null) {
    nodeRecord=getNodeStore().getRecord(nodeId);
  }
  int nextRel=nodeRecord.getNextRel();
  return new RelationshipChainPosition(nextRel);
}
Program: 154983
Project: 154983
Buggy source:
ArrayMap<Integer,PropertyData> nodeGetProperties(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord == null) {
    nodeRecord=getNodeStore().getRecord(nodeId);
  }
 else   if (!nodeRecord.inUse()) {
    throw new InvalidRecordException("String_Node_Str" + nodeId + "String_Node_Str");
  }
  int nextProp=nodeRecord.getNextProp();
  ArrayMap<Integer,PropertyData> propertyMap=new ArrayMap<Integer,PropertyData>(9,false,true);
  while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
    PropertyRecord propRecord=getPropertyRecord(nextProp);
    if (propRecord == null) {
      propRecord=getPropertyStore().getLightRecord(nextProp);
    }
    if (!propRecord.isCreated()) {
      propertyMap.put(propRecord.getKeyIndexId(),new PropertyData(propRecord.getId(),propertyGetValueOrNull(propRecord)));
    }
    nextProp=propRecord.getNextProp();
  }
  return propertyMap;
}

Fixed version (ground truth):
ArrayMap<Integer,PropertyData> nodeGetProperties(int nodeId){
  NodeRecord nodeRecord=getNodeRecord(nodeId);
  if (nodeRecord != null) {
    if (!nodeRecord.inUse()) {
      throw new IllegalStateException("String_Node_Str" + nodeId + "String_Node_Str");
    }
  }
 else {
    nodeRecord=getNodeStore().getRecord(nodeId);
  }
  if (!nodeRecord.inUse()) {
    throw new InvalidRecordException("String_Node_Str" + nodeId + "String_Node_Str");
  }
  int nextProp=nodeRecord.getNextProp();
  ArrayMap<Integer,PropertyData> propertyMap=new ArrayMap<Integer,PropertyData>(9,false,true);
  while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
    PropertyRecord propRecord=getPropertyRecord(nextProp);
    if (propRecord == null) {
      propRecord=getPropertyStore().getLightRecord(nextProp);
    }
    if (!propRecord.isCreated()) {
      propertyMap.put(propRecord.getKeyIndexId(),new PropertyData(propRecord.getId(),propertyGetValueOrNull(propRecord)));
    }
    nextProp=propRecord.getNextProp();
  }
  return propertyMap;
}
Program: 154984
Project: 154984
Buggy source:
private Collection<Path> least(Map<Integer,List<Path>> hits){
  if (hits.size() == 0) {
    return Collections.emptyList();
  }
  for (int i=0; true; i++) {
    List<Path> paths=hits.get(i);
    if (paths != null) {
      return paths;
    }
  }
}

Fixed version (ground truth):
private Collection<Path> least(Map<Integer,Collection<Hit>> hits){
  if (hits.size() == 0) {
    return Collections.emptyList();
  }
  for (int i=0; true; i++) {
    Collection<Hit> depthHits=hits.get(i);
    if (depthHits != null) {
      return hitsToPaths(depthHits);
    }
  }
}
Program: 154985
Project: 154985
Buggy source:
DirectionData(String name,Node startNode,Collection<Long> sharedVisitedRels,FrozenDepth sharedFrozenDepth,MutableBoolean sharedStop,MutableInteger sharedCurrentDepth){
  this.name=name;
  this.visitedNodes.put(startNode,new LevelData(startNode,currentDepth,new Path.Builder(startNode)));
  this.nextNodes.add(startNode);
  this.sharedVisitedRels=sharedVisitedRels;
  this.sharedFrozenDepth=sharedFrozenDepth;
  this.sharedStop=sharedStop;
  this.sharedCurrentDepth=sharedCurrentDepth;
  prepareNextLevel();
}

Fixed version (ground truth):
DirectionData(String name,Node startNode,Collection<Long> sharedVisitedRels,ValueHolder<Integer> sharedFrozenDepth,ValueHolder<Boolean> sharedStop,ValueHolder<Integer> sharedCurrentDepth){
  this.visitedNodes.put(startNode,new LevelData(startNode,currentDepth,new Path.Builder(startNode)));
  this.nextNodes.add(startNode);
  this.sharedFrozenDepth=sharedFrozenDepth;
  this.sharedStop=sharedStop;
  this.sharedCurrentDepth=sharedCurrentDepth;
  prepareNextLevel();
}
Program: 154986
Project: 154986
Buggy source:
private void goOneStep(DirectionData directionData,DirectionData otherSide,Map<Integer,List<Path>> hits,boolean stopAsEarlyAsPossible,DirectionData startSide){
  if (!directionData.hasNext()) {
    return;
  }
  LevelData levelData=directionData.next();
  LevelData otherSideHit=otherSide.visitedNodes.get(levelData.node);
  if (otherSideHit != null) {
    int depth=directionData.currentDepth + otherSideHit.depth;
    if (!directionData.sharedFrozenDepth.isFrozen()) {
      directionData.sharedFrozenDepth.depth=depth;
    }
    if (depth <= directionData.sharedFrozenDepth.depth) {
      directionData.haveFoundSomething=true;
      if (depth < directionData.sharedFrozenDepth.depth) {
        directionData.sharedFrozenDepth.depth=depth;
        otherSide.stop=true;
        if (stopAsEarlyAsPossible) {
          directionData.sharedStop.value=true;
        }
      }
      List<Path> paths=hits.get(depth);
      if (paths == null) {
        paths=new ArrayList<Path>();
        hits.put(depth,paths);
      }
      Path.Builder startPath=directionData == startSide ? levelData.path : otherSideHit.path;
      Path.Builder endPath=directionData == startSide ? otherSideHit.path : levelData.path;
      paths.add(startPath.build(endPath));
    }
    if (depth == 1) {
      directionData.sharedStop.value=true;
    }
  }
}

Fixed version (ground truth):
private void goOneStep(DirectionData directionData,DirectionData otherSide,Map<Integer,Collection<Hit>> hits,boolean stopAsEarlyAsPossible,DirectionData startSide){
  if (!directionData.hasNext()) {
    return;
  }
  LevelData levelData=directionData.next();
  LevelData otherSideHit=otherSide.visitedNodes.get(levelData.node);
  if (otherSideHit != null) {
    int depth=directionData.currentDepth + otherSideHit.depth;
    if (directionData.sharedFrozenDepth.value == null) {
      directionData.sharedFrozenDepth.value=depth;
    }
    if (depth <= directionData.sharedFrozenDepth.value) {
      directionData.haveFoundSomething=true;
      if (depth < directionData.sharedFrozenDepth.value) {
        directionData.sharedFrozenDepth.value=depth;
        otherSide.stop=true;
        if (stopAsEarlyAsPossible) {
          directionData.sharedStop.value=true;
        }
      }
      Collection<Hit> depthHits=hits.get(depth);
      if (depthHits == null) {
        depthHits=new HashSet<Hit>();
        hits.put(depth,depthHits);
      }
      LevelData startSideData=directionData == startSide ? levelData : otherSideHit;
      LevelData endSideData=directionData == startSide ? otherSideHit : levelData;
      depthHits.add(new Hit(startSideData,endSideData));
    }
  }
}
Program: 154987
Project: 154987
Buggy source:
@Override protected Iterator<Relationship> createNestedIterator(Node node){
  lastParentTraverserNode=node;
  return relExpander.expand(node).iterator();
}

Fixed version (ground truth):
@Override protected Iterator<Relationship> createNestedIterator(Node node){
  lastParentTraverserNode=node;
  lastParentLevelData=visitedNodes.get(node);
  return relExpander.expand(node).iterator();
}
Program: 154988
Project: 154988
Buggy source:
private void prepareNextLevel(){
  Collection<Node> nodesToIterate=new ArrayList<Node>(this.nextNodes);
  this.nextNodes.clear();
  this.nextRelationships=new NestingIterator<Relationship,Node>(nodesToIterate.iterator()){
    @Override protected Iterator<Relationship> createNestedIterator(    Node node){
      lastParentTraverserNode=node;
      return relExpander.expand(node).iterator();
    }
  }
;
  this.currentDepth++;
  this.sharedCurrentDepth.value++;
}

Fixed version (ground truth):
private void prepareNextLevel(){
  Collection<Node> nodesToIterate=new ArrayList<Node>(this.nextNodes);
  this.nextNodes.clear();
  this.nextRelationships=new NestingIterator<Relationship,Node>(nodesToIterate.iterator()){
    @Override protected Iterator<Relationship> createNestedIterator(    Node node){
      lastParentTraverserNode=node;
      lastParentLevelData=visitedNodes.get(node);
      return relExpander.expand(node).iterator();
    }
  }
;
  this.currentDepth++;
  this.sharedCurrentDepth.value++;
}
Program: 154989
Project: 154989
Buggy source:
private boolean canGoDeeper(){
  return !this.sharedFrozenDepth.isFrozen() && this.sharedCurrentDepth.value < maxDepth;
}

Fixed version (ground truth):
private boolean canGoDeeper(){
  return this.sharedFrozenDepth.value == null && this.sharedCurrentDepth.value < maxDepth;
}
Program: 154990
Project: 154990
Buggy source:
private Collection<Path> internalPaths(Node start,Node end,boolean stopAsap){
  if (start.equals(end)) {
    return Arrays.asList(Path.singular(start));
  }
  Map<Integer,List<Path>> hits=new HashMap<Integer,List<Path>>();
  Collection<Long> sharedVisitedRels=new HashSet<Long>();
  FrozenDepth sharedFrozenDepth=new FrozenDepth();
  MutableBoolean sharedStop=new MutableBoolean();
  MutableInteger sharedCurrentDepth=new MutableInteger();
  final DirectionData startData=new DirectionData("String_Node_Str",start,sharedVisitedRels,sharedFrozenDepth,sharedStop,sharedCurrentDepth);
  final DirectionData endData=new DirectionData("String_Node_Str",end,sharedVisitedRels,sharedFrozenDepth,sharedStop,sharedCurrentDepth);
  while (startData.hasNext() || endData.hasNext()) {
    goOneStep(startData,endData,hits,stopAsap,startData);
    goOneStep(endData,startData,hits,stopAsap,startData);
  }
  return least(hits);
}

Fixed version (ground truth):
private Collection<Path> internalPaths(Node start,Node end,boolean stopAsap){
  if (start.equals(end)) {
    return Arrays.asList(Path.singular(start));
  }
  Map<Integer,Collection<Hit>> hits=new HashMap<Integer,Collection<Hit>>();
  Collection<Long> sharedVisitedRels=new HashSet<Long>();
  ValueHolder<Integer> sharedFrozenDepth=new ValueHolder<Integer>(null);
  ValueHolder<Boolean> sharedStop=new ValueHolder<Boolean>(false);
  ValueHolder<Integer> sharedCurrentDepth=new ValueHolder<Integer>(0);
  final DirectionData startData=new DirectionData("String_Node_Str",start,sharedVisitedRels,sharedFrozenDepth,sharedStop,sharedCurrentDepth);
  final DirectionData endData=new DirectionData("String_Node_Str",end,sharedVisitedRels,sharedFrozenDepth,sharedStop,sharedCurrentDepth);
  while (startData.hasNext() || endData.hasNext()) {
    goOneStep(startData,endData,hits,stopAsap,startData);
    goOneStep(endData,startData,hits,stopAsap,startData);
  }
  return least(hits);
}
Program: 154991
Project: 154991
Buggy source:
@Override protected LevelData fetchNextOrNull(){
  while (true) {
    Relationship nextRel=fetchNextRelOrNull();
    if (nextRel == null) {
      return null;
    }
    if (!sharedVisitedRels.add(nextRel.getId())) {
      continue;
    }
    Node result=nextRel.getOtherNode(this.lastParentTraverserNode);
    if (this.visitedNodes.containsKey(result)) {
      continue;
    }
    Path.Builder parentPath=this.visitedNodes.get(lastParentTraverserNode).path;
    LevelData levelData=new LevelData(result,currentDepth,parentPath.push(nextRel));
    this.visitedNodes.put(result,levelData);
    this.nextNodes.add(result);
    return levelData;
  }
}

Fixed version (ground truth):
@Override protected LevelData fetchNextOrNull(){
  while (true) {
    Relationship nextRel=fetchNextRelOrNull();
    if (nextRel == null) {
      return null;
    }
    Node result=nextRel.getOtherNode(this.lastParentTraverserNode);
    LevelData levelData=this.visitedNodes.get(result);
    boolean createdLevelData=false;
    if (levelData == null) {
      levelData=new LevelData(result,this.currentDepth);
      this.visitedNodes.put(result,levelData);
      createdLevelData=true;
    }
    if (this.currentDepth < levelData.depth) {
      throw new RuntimeException("String_Node_Str");
    }
 else     if (this.currentDepth == levelData.depth) {
      for (      Path.Builder parentPath : this.lastParentLevelData.paths) {
        levelData.paths.add(parentPath.push(nextRel));
      }
    }
    if (!createdLevelData) {
      continue;
    }
    this.nextNodes.add(result);
    return levelData;
  }
}
Program: 154992
Project: 154992
Buggy source:
private Relationship fetchNextRelOrNull(){
  boolean stopped=this.stop || this.sharedStop.value;
  boolean hasComeTooFarEmptyHanded=this.sharedFrozenDepth.isFrozen() && sharedCurrentDepth.value > sharedFrozenDepth.depth && !this.haveFoundSomething;
  if (stopped || hasComeTooFarEmptyHanded) {
    return null;
  }
  if (!this.nextRelationships.hasNext()) {
    if (canGoDeeper()) {
      prepareNextLevel();
    }
  }
  return this.nextRelationships.hasNext() ? this.nextRelationships.next() : null;
}

Fixed version (ground truth):
private Relationship fetchNextRelOrNull(){
  boolean stopped=this.stop || this.sharedStop.value;
  boolean hasComeTooFarEmptyHanded=this.sharedFrozenDepth.value != null && this.sharedCurrentDepth.value > this.sharedFrozenDepth.value && !this.haveFoundSomething;
  if (stopped || hasComeTooFarEmptyHanded) {
    return null;
  }
  if (!this.nextRelationships.hasNext()) {
    if (canGoDeeper()) {
      prepareNextLevel();
    }
  }
  return this.nextRelationships.hasNext() ? this.nextRelationships.next() : null;
}
Program: 154993
Project: 154993
Buggy source:
LevelData(Node node,int depth,Path.Builder pathToHere){
  this.node=node;
  this.depth=depth;
  this.path=pathToHere;
}

Fixed version (ground truth):
LevelData(Node node,int depth,Path.Builder... pathsToHere){
  this.node=node;
  this.depth=depth;
  this.paths.addAll(Arrays.asList(pathsToHere));
}
Program: 154994
Project: 154994
Buggy source:
/** 
 * Creates a new relationship type store contained in <CODE>fileName</CODE> If filename is <CODE>null</CODE> or the file already exists an  <CODE>IOException</CODE> is thrown.
 * @param fileName File name of the new relationship type store
 * @throws IOException If unable to create store or name null
 */
public static void createStore(String fileName){
  createEmptyStore(fileName,VERSION);
  DynamicStringStore.createStore(fileName + "String_Node_Str",TYPE_STORE_BLOCK_SIZE);
  RelationshipTypeStore store=new RelationshipTypeStore(fileName);
  store.markAsReserved(store.nextId());
  store.markAsReserved(store.nextId());
  store.markAsReserved(store.nextId());
  store.close();
}

Fixed version (ground truth):
/** 
 * Creates a new relationship type store contained in <CODE>fileName</CODE> If filename is <CODE>null</CODE> or the file already exists an  <CODE>IOException</CODE> is thrown.
 * @param fileName File name of the new relationship type store
 * @throws IOException If unable to create store or name null
 */
public static void createStore(String fileName){
  createEmptyStore(fileName,VERSION);
  DynamicStringStore.createStore(fileName + "String_Node_Str",TYPE_STORE_BLOCK_SIZE);
  RelationshipTypeStore store=new RelationshipTypeStore(fileName);
  store.close();
}
Program: 154995
Project: 154995
Buggy source:
DirectMappedLogBuffer(FileChannel fileChannel) throws IOException {
  this.fileChannel=fileChannel;
  bufferStartPosition=fileChannel.position();
  byteBuffer=ByteBuffer.allocateDirect(BUFFER_SIZE);
  getNewMappedBuffer();
}

Fixed version (ground truth):
DirectMappedLogBuffer(FileChannel fileChannel) throws IOException {
  this.fileChannel=fileChannel;
  bufferStartPosition=fileChannel.position();
  byteBuffer=ByteBuffer.allocateDirect(BUFFER_SIZE);
}
Program: 154996
Project: 154996
Buggy source:
public LogBuffer putInt(int i) throws IOException {
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < 4) {
    getNewMappedBuffer();
  }
  byteBuffer.putInt(i);
  return this;
}

Fixed version (ground truth):
public LogBuffer putInt(int i) throws IOException {
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < 4) {
    getNewDirectBuffer();
  }
  byteBuffer.putInt(i);
  return this;
}
Program: 154997
Project: 154997
Buggy source:
public void force() throws IOException {
  getNewMappedBuffer();
  fileChannel.force(false);
}

Fixed version (ground truth):
public void force() throws IOException {
  getNewDirectBuffer();
  fileChannel.force(false);
}
Program: 154998
Project: 154998
Buggy source:
public LogBuffer putLong(long l) throws IOException {
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < 8) {
    getNewMappedBuffer();
  }
  byteBuffer.putLong(l);
  return this;
}

Fixed version (ground truth):
public LogBuffer putLong(long l) throws IOException {
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < 8) {
    getNewDirectBuffer();
  }
  byteBuffer.putLong(l);
  return this;
}
Program: 154999
Project: 154999
Buggy source:
public LogBuffer put(char[] chars) throws IOException {
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < (chars.length * 2)) {
    getNewMappedBuffer();
  }
  int oldPos=byteBuffer.position();
  byteBuffer.asCharBuffer().put(chars);
  byteBuffer.position(oldPos + chars.length * 2);
  return this;
}

Fixed version (ground truth):
private void put(char[] chars,int offset) throws IOException {
  int charsToWrite=chars.length - offset;
  if (charsToWrite * 2 > BUFFER_SIZE) {
    charsToWrite=BUFFER_SIZE / 2;
  }
  if (byteBuffer == null || (BUFFER_SIZE - byteBuffer.position()) < (charsToWrite * 2)) {
    getNewDirectBuffer();
  }
  int oldPos=byteBuffer.position();
  byteBuffer.asCharBuffer().put(chars,offset,charsToWrite);
  byteBuffer.position(oldPos + (charsToWrite * 2));
  offset+=charsToWrite;
  if (offset < chars.length) {
    put(chars,offset);
  }
}
Program: 155000
Project: 155000
Buggy source:
public synchronized void applyLog(ReadableByteChannel byteChannel) throws IOException {
  if (!backupSlave) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (xidIdentMap.size() > 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  buffer.clear();
  buffer.limit(8);
  if (byteChannel.read(buffer) != 8) {
    throw new IOException("String_Node_Str");
  }
  buffer.flip();
  logVersion=buffer.getLong();
  if (logVersion != xaTf.getCurrentVersion()) {
    throw new IllegalStateException("String_Node_Str" + logVersion + "String_Node_Str"+ xaTf.getCurrentVersion());
  }
  log.fine("String_Node_Str" + logVersion);
  long logEntriesFound=0;
  LogApplier logApplier=new LogApplier(byteChannel,buffer,xaTf,xaRm,cf,xidIdentMap,recoveredTxMap);
  while (logApplier.readAndApplyEntry()) {
    logEntriesFound++;
  }
  byteChannel.close();
  xaTf.flushAll();
  xaTf.getAndSetNewVersion();
  xaRm.reset();
  log.info("String_Node_Str" + logVersion + "String_Node_Str");
}

Fixed version (ground truth):
public synchronized void applyLog(ReadableByteChannel byteChannel) throws IOException {
  if (!backupSlave) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (xidIdentMap.size() > 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  buffer.clear();
  buffer.limit(8);
  if (byteChannel.read(buffer) != 8) {
    throw new IOException("String_Node_Str");
  }
  buffer.flip();
  logVersion=buffer.getLong();
  if (logVersion != xaTf.getCurrentVersion()) {
    throw new IllegalStateException("String_Node_Str" + logVersion + "String_Node_Str"+ xaTf.getCurrentVersion());
  }
  log.fine("String_Node_Str" + logVersion);
  long logEntriesFound=0;
  LogApplier logApplier=new LogApplier(byteChannel,buffer,xaTf,xaRm,cf,xidIdentMap,recoveredTxMap);
  while (logApplier.readAndApplyEntry()) {
    logEntriesFound++;
  }
  byteChannel.close();
  xaTf.flushAll();
  xaTf.getAndSetNewVersion();
  xaRm.reset();
  log.info("String_Node_Str" + fileName + "String_Node_Str"+ logVersion+ "String_Node_Str");
}
Program: 155001
Project: 155001
Buggy source:
private void deleteCurrentLogFile(String logFileName) throws IOException {
  releaseCurrentLogFile();
  File file=new File(logFileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + logFileName + "String_Node_Str");
  }
  boolean deleted=FileUtils.deleteFile(file);
  if (!deleted) {
    log.warning("String_Node_Str" + logFileName + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void deleteCurrentLogFile(String logFileName) throws IOException {
  File file=new File(logFileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + logFileName + "String_Node_Str");
  }
  boolean deleted=FileUtils.deleteFile(file);
  if (!deleted) {
    log.warning("String_Node_Str" + logFileName + "String_Node_Str");
  }
}
Program: 155002
Project: 155002
Buggy source:
public synchronized void close() throws IOException {
  if (fileChannel == null || !fileChannel.isOpen()) {
    log.fine("String_Node_Str" + fileName + "String_Node_Str");
    return;
  }
  long endPosition=writeBuffer.getFileChannelPosition();
  if (xidIdentMap.size() > 0) {
    log.info("String_Node_Str" + xidIdentMap.size() + "String_Node_Str");
    writeBuffer.force();
    writeBuffer=null;
    fileChannel.close();
    log.info("String_Node_Str" + fileName + "String_Node_Str"+ currentLog+ "String_Node_Str"+ "String_Node_Str");
    return;
  }
  if (!keepLogs || backupSlave) {
    if (currentLog == CLEAN) {
      deleteCurrentLogFile(fileName);
    }
 else {
      deleteCurrentLogFile(fileName + "String_Node_Str" + currentLog);
    }
  }
 else {
    renameCurrentLogFileAndIncrementVersion(fileName + "String_Node_Str" + currentLog,endPosition);
  }
  if (currentLog != CLEAN) {
    setActiveLog(CLEAN);
  }
}

Fixed version (ground truth):
public synchronized void close() throws IOException {
  if (fileChannel == null || !fileChannel.isOpen()) {
    log.fine("String_Node_Str" + fileName + "String_Node_Str");
    return;
  }
  long endPosition=writeBuffer.getFileChannelPosition();
  if (xidIdentMap.size() > 0) {
    log.info("String_Node_Str" + xidIdentMap.size() + "String_Node_Str");
    writeBuffer.force();
    writeBuffer=null;
    fileChannel.close();
    log.info("String_Node_Str" + fileName + "String_Node_Str"+ currentLog+ "String_Node_Str"+ "String_Node_Str");
    return;
  }
  releaseCurrentLogFile();
  char logWas=currentLog;
  if (currentLog != CLEAN) {
    setActiveLog(CLEAN);
  }
  if (!keepLogs || backupSlave) {
    if (logWas == CLEAN) {
      deleteCurrentLogFile(fileName);
    }
 else {
      deleteCurrentLogFile(fileName + "String_Node_Str" + logWas);
    }
  }
 else {
    renameCurrentLogFileAndIncrementVersion(fileName + "String_Node_Str" + logWas,endPosition);
  }
}
Program: 155003
Project: 155003
Buggy source:
private void renameCurrentLogFileAndIncrementVersion(String logFileName,long endPosition) throws IOException {
  releaseCurrentLogFile();
  File file=new File(logFileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + logFileName + "String_Node_Str");
  }
  String newName=fileName + "String_Node_Str" + xaTf.getAndSetNewVersion();
  File newFile=new File(newName);
  boolean renamed=FileUtils.renameFile(file,newFile);
  if (!renamed) {
    throw new IOException("String_Node_Str" + newName);
  }
 else {
    try {
      FileChannel channel=new RandomAccessFile(newName,"String_Node_Str").getChannel();
      FileUtils.truncateFile(channel,endPosition);
    }
 catch (    IOException e) {
      log.log(Level.WARNING,"String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void renameCurrentLogFileAndIncrementVersion(String logFileName,long endPosition) throws IOException {
  File file=new File(logFileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + logFileName + "String_Node_Str");
  }
  String newName=fileName + "String_Node_Str" + xaTf.getAndSetNewVersion();
  File newFile=new File(newName);
  boolean renamed=FileUtils.renameFile(file,newFile);
  if (!renamed) {
    throw new IOException("String_Node_Str" + newName);
  }
 else {
    try {
      FileChannel channel=new RandomAccessFile(newName,"String_Node_Str").getChannel();
      FileUtils.truncateFile(channel,endPosition);
    }
 catch (    IOException e) {
      log.log(Level.WARNING,"String_Node_Str",e);
    }
  }
}
Program: 155005
Project: 155005
Buggy source:
public void run(){
  try {
    while (run) {
      Long logVersion=queue.poll();
      if (logVersion != null) {
        if (logVersion == xaDs.getCurrentLogVersion()) {
          ReadableByteChannel logChannel=xaDs.getLogicalLog(logVersion);
          xaDs.applyLog(logChannel);
        }
      }
 else {
synchronized (this) {
          try {
            this.wait(250);
          }
 catch (          InterruptedException e) {
            interrupted();
          }
        }
      }
    }
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
    e.printStackTrace();
  }
 finally {
    run=false;
  }
}

Fixed version (ground truth):
public void run(){
  try {
    while (run) {
      long logVersion=xaDs.getCurrentLogVersion();
      if (xaDs.hasLogicalLog(logVersion)) {
        ReadableByteChannel logChannel=xaDs.getLogicalLog(logVersion);
        xaDs.applyLog(logChannel);
      }
 else {
synchronized (this) {
          try {
            this.wait(250);
          }
 catch (          InterruptedException e) {
            interrupted();
          }
        }
      }
    }
  }
 catch (  IOException e) {
    System.err.println("String_Node_Str" + e);
    e.printStackTrace();
  }
 finally {
    run=false;
  }
}
Program: 155006
Project: 155006
Buggy source:
public void rotateLogAndPushToSlaves() throws IOException {
  long version=getVersion();
  xaDs.rotateLogicalLog();
  for (  HandleSlaveConnection slave : slaveList) {
    if (!slave.offerLogToSlave(version)) {
      System.out.println("String_Node_Str" + slave);
    }
  }
}

Fixed version (ground truth):
public void rotateLogAndPushToSlaves() throws IOException {
  if (slaveList.size() == 0) {
    return;
  }
  long version=getVersion();
  xaDs.rotateLogicalLog();
  ArrayList<HandleSlaveConnection> newList=new ArrayList<HandleSlaveConnection>();
  for (  HandleSlaveConnection slave : slaveList) {
    if (!slave.offerLogToSlave(version)) {
      System.out.println("String_Node_Str" + slave);
    }
 else {
      newList.add(slave);
    }
  }
  slaveList=newList;
}
Program: 155007
Project: 155007
Buggy source:
public ReadOnlySlave(String path,Map<String,String> params,String masterIp,int masterPort){
  this.graphDb=new EmbeddedReadOnlyGraphDatabase(path,params);
  this.xaDs=(NeoStoreXaDataSource)graphDb.getConfig().getTxModule().getXaDataSourceManager().getXaDataSource("String_Node_Str");
  this.xaDs.makeBackupSlave();
  recover();
  jobEater=new JobEater();
  logApplier=new LogApplier(xaDs);
  jobEater.start();
  logApplier.start();
  this.masterIp=masterIp;
  this.masterPort=masterPort;
  masterConnection=new Connection(masterIp,masterPort);
  if (!masterConnection.connected()) {
    if (masterConnection.connectionRefused()) {
      throw new SocketException("String_Node_Str" + masterIp + "String_Node_Str"+ masterPort+ "String_Node_Str");
    }
  }
  jobEater.addJob(new ConnectToMasterJob(masterConnection,this));
}

Fixed version (ground truth):
public ReadOnlySlave(String path,Map<String,String> params,String masterIp,int masterPort){
  this.graphDb=new EmbeddedGraphDatabase(path,params);
  this.xaDs=(NeoStoreXaDataSource)graphDb.getConfig().getTxModule().getXaDataSourceManager().getXaDataSource("String_Node_Str");
  this.xaDs.makeBackupSlave();
  recover();
  jobEater=new JobEater();
  logApplier=new LogApplier(xaDs);
  jobEater.start();
  logApplier.start();
  this.masterIp=masterIp;
  this.masterPort=masterPort;
  masterConnection=new Connection(masterIp,masterPort);
  while (!masterConnection.connected()) {
    if (masterConnection.connectionRefused()) {
      throw new SocketException("String_Node_Str" + masterIp + "String_Node_Str"+ masterPort+ "String_Node_Str");
    }
  }
  jobEater.addJob(new ConnectToMasterJob(masterConnection,this));
}
Program: 155008
Project: 155008
Buggy source:
public boolean connected(){
  if (!channel.isBlocking() && !channel.isConnected() && channel.isConnectionPending()) {
    try {
      channel.finishConnect();
    }
 catch (    IOException e) {
      connectionRefused=true;
    }
  }
  return channel.isConnected();
}

Fixed version (ground truth):
public boolean connected(){
  if (!channel.isBlocking() && !channel.isConnected() && channel.isConnectionPending()) {
    try {
      return channel.finishConnect();
    }
 catch (    IOException e) {
      connectionRefused=true;
    }
  }
  return channel.isConnected();
}
Program: 155009
Project: 155009
Buggy source:
private boolean setupRequest(){
  long version=slave.getVersion() + 1;
  while (version < masterVersion) {
    if (slave.hasLog(version)) {
      version++;
    }
 else {
      break;
    }
  }
  if (version == masterVersion) {
    setStatus(Status.GET_MESSAGE);
    return true;
  }
  if (retries > 20) {
    close();
  }
  if (!acquireWriteBuffer()) {
    retries++;
    return false;
  }
  buffer.put(HeaderConstants.REQUEST_LOG);
  buffer.putLong(version);
  buffer.flip();
  log("String_Node_Str" + version);
  setStatus(Status.SEND_REQUEST);
  retries=0;
  return true;
}

Fixed version (ground truth):
private boolean setupRequest(){
  long version=slave.getVersion();
  while (version < masterVersion) {
    if (slave.hasLog(version)) {
      version++;
    }
 else {
      break;
    }
  }
  if (version == masterVersion) {
    setStatus(Status.GET_MESSAGE);
    return true;
  }
  if (retries > 20) {
    close();
  }
  if (!acquireWriteBuffer()) {
    retries++;
    return false;
  }
  buffer.put(HeaderConstants.REQUEST_LOG);
  buffer.putLong(version);
  buffer.flip();
  log("String_Node_Str" + version);
  setStatus(Status.SEND_REQUEST);
  retries=0;
  return true;
}
Program: 155010
Project: 155010
Buggy source:
private boolean getLog(){
  if (!acquireReadBuffer()) {
    return false;
  }
  log("String_Node_Str");
  try {
    int read=connection.read();
    if (read > 0) {
      buffer.flip();
      if (logToWrite.position() + read <= logLength) {
        logToWrite.write(buffer);
      }
 else {
        int readLimit=buffer.limit();
        int logLimit=(int)(logLength - logToWrite.position());
        buffer.limit(logLimit);
        logToWrite.write(buffer);
        buffer.limit(readLimit);
        byte[] pushData=new byte[readLimit - logLimit];
        buffer.get(pushData);
        connection.pushBackReadData(pushData);
      }
      if (logToWrite.position() >= logLength) {
        log("String_Node_Str");
        if (slave.getVersion() < (masterVersion - 1)) {
          setStatus(Status.SETUP_REQUEST);
        }
 else {
          setStatus(Status.GET_MESSAGE);
        }
        logToWrite.close();
        tempFile.renameTo(new File(slave.getLogName(logVersionWriting)));
        logVersionWriting=-1;
        tempFile=null;
        logToWrite=null;
        slave.tryApplyNewLog();
      }
      return true;
    }
 else {
      return false;
    }
  }
 catch (  IOException e) {
    close();
    log("String_Node_Str",e);
    return true;
  }
 finally {
    releaseReadBuffer();
  }
}

Fixed version (ground truth):
private boolean getLog(){
  if (!acquireReadBuffer()) {
    return false;
  }
  log("String_Node_Str");
  try {
    int read=connection.read();
    if (read > 0) {
      buffer.flip();
      if (logToWrite.position() + read <= logLength) {
        logToWrite.write(buffer);
      }
 else {
        int readLimit=buffer.limit();
        int logLimit=(int)(logLength - logToWrite.position());
        buffer.limit(logLimit);
        logToWrite.write(buffer);
        buffer.limit(readLimit);
        byte[] pushData=new byte[readLimit - logLimit];
        buffer.get(pushData);
        connection.pushBackReadData(pushData);
      }
      if (logToWrite.position() >= logLength) {
        log("String_Node_Str");
        if (slave.getVersion() < (masterVersion - 1)) {
          setStatus(Status.SETUP_REQUEST);
        }
 else {
          setStatus(Status.GET_MESSAGE);
        }
        logToWrite.close();
        String newName=slave.getLogName(logVersionWriting);
        File newLog=new File(newName);
        if (newLog.exists()) {
          log("String_Node_Str" + newName + "String_Node_Str");
          close();
        }
        if (!tempFile.renameTo(new File(newName))) {
          log("String_Node_Str" + newName);
          close();
        }
        logVersionWriting=-1;
        tempFile=null;
        logToWrite=null;
      }
      return true;
    }
 else {
      return false;
    }
  }
 catch (  IOException e) {
    close();
    log("String_Node_Str",e);
    return true;
  }
 finally {
    releaseReadBuffer();
  }
}