Program: 113384
Project: 113384
Buggy source:
private void removeReadOutdated(String volumeName,String fileName) throws Exception {
  AdminVolume volume=client.openVolume(volumeName,null,options);
  AdminFileHandle fileHandle=volume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_CREAT,SYSTEM_V_FCNTL_H_O_RDWR),0777);
  int count=256 * 1024;
  ReusableBuffer data=SetupUtils.generateData(count,(byte)1);
  System.out.println("String_Node_Str");
  fileHandle.write(userCredentials,data.createViewBuffer().getData(),count,0);
  fileHandle.close();
  Thread.sleep(20 * 1000);
  System.out.println("String_Node_Str");
  fileHandle=volume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_RDONLY));
  List<Replica> replicas=fileHandle.getReplicasList();
  System.out.println(replicas);
  Replica replica=replicas.get(0);
  int prevReplicaCount=fileHandle.getReplicasList().size();
  System.out.println("String_Node_Str" + replica.getOsdUuids(0));
  assertEquals(1,replica.getOsdUuidsCount());
  AdminVolume controlVolume=client.openVolume(volumeName,null,options);
  controlVolume.removeReplica(userCredentials,fileName,replica.getOsdUuids(0));
  AdminFileHandle controlFile=controlVolume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_RDONLY));
  assertEquals(controlFile.getReplicasList().size(),prevReplicaCount - 1);
  System.out.println(controlFile.getReplicasList());
  controlFile.close();
  controlVolume.close();
  System.out.println("String_Node_Str");
  Thread.sleep(70 * 1000);
  byte[] data2=new byte[1];
  fileHandle.read(userCredentials,data2,1,0);
  fileHandle.close();
  assertEquals(data2[0],(byte)1);
  volume.close();
}

Fixed version (ground truth):
private void removeReadOutdated(String volumeName,String fileName) throws Exception {
  AdminVolume volume=client.openVolume(volumeName,null,options);
  AdminFileHandle fileHandle=volume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_CREAT,SYSTEM_V_FCNTL_H_O_RDWR),0777);
  int count=256 * 1024;
  ReusableBuffer data=SetupUtils.generateData(count,(byte)1);
  System.out.println("String_Node_Str");
  fileHandle.write(userCredentials,data.createViewBuffer().getData(),count,0);
  fileHandle.close();
  Thread.sleep(20 * 1000);
  System.out.println("String_Node_Str");
  fileHandle=volume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_RDONLY));
  List<Replica> replicas=fileHandle.getReplicasList();
  System.out.println(replicas);
  Replica replica=replicas.get(0);
  int prevReplicaCount=fileHandle.getReplicasList().size();
  System.out.println("String_Node_Str" + replica.getOsdUuids(0));
  assertEquals(1,replica.getOsdUuidsCount());
  AdminVolume controlVolume=client.openVolume(volumeName,null,options);
  controlVolume.removeReplica(userCredentials,fileName,replica.getOsdUuids(0));
  AdminFileHandle controlFile=controlVolume.openFile(userCredentials,fileName,Helper.flagsToInt(SYSTEM_V_FCNTL_H_O_RDONLY));
  assertEquals(controlFile.getReplicasList().size(),prevReplicaCount - 1);
  System.out.println(controlFile.getReplicasList());
  controlFile.close();
  controlVolume.close();
  System.out.println("String_Node_Str");
  Thread.sleep(70 * 1000);
  System.out.println("String_Node_Str");
  readInvalidView(fileHandle);
  fileHandle.close();
  volume.close();
}