nus-yam/ex-repair huggingface dataset:
Program: 55500
Project: 55500
Buggy source:
/** 
 * Creates an new ChannelWriterOutputView that writes to the given channel. It uses only a single memory segment for the buffering, which it takes from the writers return queue.
 * @param writer The writer to write to.
 * @param segmentSize The size of the memory segments.
 */
public ChannelWriterOutputView(BlockChannelWriter writer,int segmentSize){
  this(writer,null,segmentSize);
}

Fixed version (ground truth):
/** 
 * Creates an new ChannelWriterOutputView that writes to the given channel. It uses only a single memory segment for the buffering, which it takes from the writers return queue. Note that this variant locks if no buffers are contained in the return queue.
 * @param writer The writer to write to.
 * @param segmentSize The size of the memory segments.
 */
public ChannelWriterOutputView(BlockChannelWriter writer,int segmentSize){
  this(writer,null,segmentSize);
}
Program: 55501
Project: 55501
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void processEvent(final AbstractEvent event){
  if (event instanceof ByteBufferedChannelCloseEvent) {
    LOG.info("String_Node_Str");
  }
 else   if (event instanceof UnexpectedEnvelopeEvent) {
    final UnexpectedEnvelopeEvent uee=(UnexpectedEnvelopeEvent)event;
    if (uee.getExpectedSequenceNumber() > this.nextEnvelopeToSend) {
      this.nextEnvelopeToSend=uee.getExpectedSequenceNumber();
    }
  }
 else   if (event instanceof ReceiverNotFoundEvent) {
    final ReceiverNotFoundEvent rnfe=(ReceiverNotFoundEvent)event;
    LOG.warn("String_Node_Str" + rnfe.getReceiverID() + "String_Node_Str"+ rnfe.getSequenceNumber());
  }
 else {
    LOG.warn("String_Node_Str" + event);
  }
  getNext().processEvent(event);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void processEvent(final AbstractEvent event){
  if (event instanceof ByteBufferedChannelCloseEvent) {
    LOG.info("String_Node_Str");
  }
 else   if (event instanceof UnexpectedEnvelopeEvent) {
    final UnexpectedEnvelopeEvent uee=(UnexpectedEnvelopeEvent)event;
    if (uee.getExpectedSequenceNumber() > this.nextEnvelopeToSend) {
      this.nextEnvelopeToSend=uee.getExpectedSequenceNumber();
    }
  }
 else   if (event instanceof ReceiverNotFoundEvent) {
    final ReceiverNotFoundEvent rnfe=(ReceiverNotFoundEvent)event;
    LOG.warn("String_Node_Str" + rnfe.getReceiverID() + "String_Node_Str"+ rnfe.getSequenceNumber()+ "String_Node_Str"+ this.nextEnvelopeToSend);
  }
 else {
    LOG.warn("String_Node_Str" + event);
  }
  getNext().processEvent(event);
}
Program: 55503
Project: 55503
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  changeExecutionState(ExecutionState.REPLAYING,null);
  if (this.executionObserver.isCanceled()) {
    changeExecutionState(ExecutionState.CANCELED,null);
    return;
  }
  resetAllOutputBroker();
  try {
    replayCheckpoint();
    if (this.executionObserver.isCanceled()) {
      throw new InterruptedException();
    }
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  changeExecutionState(ExecutionState.REPLAYING,null);
  if (this.executionObserver.isCanceled()) {
    changeExecutionState(ExecutionState.CANCELED,null);
    return;
  }
  try {
    replayCheckpoint();
    if (this.executionObserver.isCanceled()) {
      throw new InterruptedException();
    }
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}
Program: 55504
Project: 55504
Buggy source:
void restart(){
  changeExecutionState(ExecutionState.STARTING,null);
  this.restartRequested.set(true);
  interrupt();
  this.interruptCalled.set(true);
}

Fixed version (ground truth):
void restart(){
  changeExecutionState(ExecutionState.STARTING,null);
  this.restartRequested.set(true);
  changeExecutionState(ExecutionState.REPLAYING,null);
}
Program: 55506
Project: 55506
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  while (true) {
    changeExecutionState(ExecutionState.REPLAYING,null);
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
      return;
    }
    resetAllOutputBroker();
    try {
      replayCheckpoint();
      if (this.executionObserver.isCanceled()) {
        throw new InterruptedException();
      }
    }
 catch (    Exception e) {
      if (isRestartRequested()) {
        continue;
      }
      if (this.executionObserver.isCanceled()) {
        changeExecutionState(ExecutionState.CANCELED,null);
      }
 else {
        changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
      }
      return;
    }
    if (isRestartRequested()) {
      continue;
    }
    break;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  changeExecutionState(ExecutionState.REPLAYING,null);
  if (this.executionObserver.isCanceled()) {
    changeExecutionState(ExecutionState.CANCELED,null);
    return;
  }
  resetAllOutputBroker();
  try {
    replayCheckpoint();
    if (this.executionObserver.isCanceled()) {
      throw new InterruptedException();
    }
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}
Program: 55507
Project: 55507
Buggy source:
boolean followsLog(){
  if (this.numberOfInitialLogEntries == 0) {
    return false;
  }
synchronized (this) {
    return this.announcedEnvelopesAsIntBuffer.hasRemaining();
  }
}

Fixed version (ground truth):
boolean followsLog(){
  if (this.numberOfInitialLogEntries == 0) {
    return false;
  }
synchronized (this) {
    return this.outstandingEnvelopesAsIntBuffer.hasRemaining();
  }
}
Program: 55508
Project: 55508
Buggy source:
@Override public Schema create(Iterable<EvaluationExpression> keyExpressions){
  List<ObjectAccess> objectAccesses=new ArrayList<ObjectAccess>();
  List<ArrayAccess> arrayAccesses=new ArrayList<ArrayAccess>();
  List<EvaluationExpression> mappings=new ArrayList<EvaluationExpression>();
  for (  EvaluationExpression evaluationExpression : keyExpressions) {
    mappings.add(evaluationExpression);
    if (evaluationExpression instanceof ObjectAccess) {
      objectAccesses.add((ObjectAccess)evaluationExpression);
    }
    if (evaluationExpression instanceof ArrayAccess) {
      arrayAccesses.add((ArrayAccess)evaluationExpression);
    }
  }
  if (mappings.isEmpty())   return new DirectSchema();
  if (objectAccesses.size() == mappings.size()) {
    ObjectSchema schema=new ObjectSchema();
    schema.setMappingsWithAccesses(objectAccesses);
    return schema;
  }
 else   if (arrayAccesses.size() == mappings.size()) {
    int startIndex=arrayAccesses.get(0).getStartIndex();
    int endIndex=arrayAccesses.get(arrayAccesses.size()).getEndIndex();
    if (startIndex == 0) {
      HeadArraySchema schema=new HeadArraySchema();
      schema.setHeadSize(endIndex + 1);
      return schema;
    }
 else {
      TailArraySchema schema=new TailArraySchema();
      schema.setTailSize(endIndex - startIndex + 1);
      return schema;
    }
  }
 else {
    return new GeneralSchema(mappings);
  }
}

Fixed version (ground truth):
@Override public Schema create(Iterable<EvaluationExpression> keyExpressions){
  List<ObjectAccess> objectAccesses=new ArrayList<ObjectAccess>();
  List<ArrayAccess> arrayAccesses=new ArrayList<ArrayAccess>();
  List<EvaluationExpression> mappings=new ArrayList<EvaluationExpression>();
  for (  EvaluationExpression evaluationExpression : keyExpressions) {
    mappings.add(evaluationExpression);
    if (evaluationExpression instanceof ObjectAccess) {
      objectAccesses.add((ObjectAccess)evaluationExpression);
    }
    if (evaluationExpression instanceof ArrayAccess) {
      arrayAccesses.add((ArrayAccess)evaluationExpression);
    }
  }
  if (mappings.isEmpty())   return new DirectSchema();
  if (objectAccesses.size() == mappings.size()) {
    ObjectSchema schema=new ObjectSchema();
    schema.setMappingsWithAccesses(objectAccesses);
    return schema;
  }
 else   if (arrayAccesses.size() == mappings.size()) {
    int startIndex=arrayAccesses.get(0).getStartIndex();
    int endIndex=arrayAccesses.get(arrayAccesses.size() - 1).getEndIndex();
    if (startIndex == 0) {
      HeadArraySchema schema=new HeadArraySchema();
      schema.setHeadSize(endIndex + 1);
      return schema;
    }
 else {
      TailArraySchema schema=new TailArraySchema();
      schema.setTailSize(endIndex - startIndex + 1);
      return schema;
    }
  }
 else {
    return new GeneralSchema(mappings);
  }
}
Program: 55509
Project: 55509
Buggy source:
/** 
 * Checks, if all target vertices for multicast transmisison are ready. If vertices are in state ASSIGNED, it will deploy those vertices.
 * @param caller
 * @param jobID
 * @param sourceChannelID
 * @return
 */
private boolean checkIfAllTargetVerticesReady(InstanceConnectionInfo caller,JobID jobID,ChannelID sourceChannelID){
  final ExecutionGraph eg=this.scheduler.getExecutionGraphByID(jobID);
  final AbstractOutputChannel<? extends Record> outputChannel=eg.getOutputChannelByID(sourceChannelID);
  final OutputGate<? extends Record> broadcastgate=outputChannel.getOutputGate();
  List<ExecutionVertex> verticesToDeploy=null;
  for (  AbstractOutputChannel<? extends Record> c : broadcastgate.getOutputChannels()) {
    if (c.isBroadcastChannel()) {
      ExecutionVertex targetVertex=eg.getVertexByChannelID(c.getConnectedChannelID());
      if (targetVertex.getExecutionState() == ExecutionState.ASSIGNED) {
        if (verticesToDeploy == null) {
          verticesToDeploy=new ArrayList<ExecutionVertex>();
        }
        verticesToDeploy.add(targetVertex);
      }
 else {
        if (targetVertex.getExecutionState() != ExecutionState.RUNNING && targetVertex.getExecutionState() != ExecutionState.FINISHING && targetVertex.getExecutionState() != ExecutionState.READY && targetVertex.getExecutionState() != ExecutionState.STARTING) {
          return false;
        }
      }
    }
  }
  if (verticesToDeploy != null) {
    this.scheduler.deployAssignedVertices(verticesToDeploy);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks, if all target vertices for multicast transmisison are ready. If vertices are in state ASSIGNED, it will deploy those vertices.
 * @param caller
 * @param jobID
 * @param sourceChannelID
 * @return
 */
private boolean checkIfAllTargetVerticesReady(InstanceConnectionInfo caller,JobID jobID,ChannelID sourceChannelID){
  final ExecutionGraph eg=this.scheduler.getExecutionGraphByID(jobID);
  final AbstractOutputChannel<? extends Record> outputChannel=eg.getOutputChannelByID(sourceChannelID);
  final OutputGate<? extends Record> broadcastgate=outputChannel.getOutputGate();
  List<ExecutionVertex> verticesToDeploy=null;
  for (  AbstractOutputChannel<? extends Record> c : broadcastgate.getOutputChannels()) {
    if (c.isBroadcastChannel()) {
      ExecutionVertex targetVertex=eg.getVertexByChannelID(c.getConnectedChannelID());
      if (targetVertex.getExecutionState() == ExecutionState.ASSIGNED) {
        if (verticesToDeploy == null) {
          verticesToDeploy=new ArrayList<ExecutionVertex>();
        }
        verticesToDeploy.add(targetVertex);
      }
 else {
        if (targetVertex.getExecutionState() != ExecutionState.RUNNING && targetVertex.getExecutionState() != ExecutionState.FINISHING) {
          return false;
        }
      }
    }
  }
  if (verticesToDeploy != null) {
    this.scheduler.deployAssignedVertices(verticesToDeploy);
    return false;
  }
  return true;
}
Program: 55511
Project: 55511
Buggy source:
/** 
 * Private constructor used to duplicate execution vertices.
 * @param vertexID the ID of the new execution vertex.
 * @param invokableClass the task that is assigned to this execution vertex
 * @param executionGraph the execution graph the new vertex belongs to
 * @param groupVertex the group vertex the new vertex belongs to
 * @param environment the environment for the newly created vertex
 */
private ExecutionVertex(final ExecutionVertexID vertexID,final Class<? extends AbstractInvokable> invokableClass,final ExecutionGraph executionGraph,final ExecutionGroupVertex groupVertex,final RuntimeEnvironment environment){
  this.vertexID=vertexID;
  this.invokableClass=invokableClass;
  this.executionGraph=executionGraph;
  this.groupVertex=groupVertex;
  this.environment=environment;
  this.checkpointState=new AtomicEnum<CheckpointState>(groupVertex.getInitialCheckpointState());
  this.retriesLeft=new AtomicInteger(groupVertex.getNumberOfExecutionRetries());
  registerExecutionListener(this.executionGraph);
}

Fixed version (ground truth):
/** 
 * Private constructor used to duplicate execution vertices.
 * @param vertexID the ID of the new execution vertex.
 * @param invokableClass the task that is assigned to this execution vertex
 * @param executionGraph the execution graph the new vertex belongs to
 * @param groupVertex the group vertex the new vertex belongs to
 * @param environment the environment for the newly created vertex
 */
private ExecutionVertex(final ExecutionVertexID vertexID,final Class<? extends AbstractInvokable> invokableClass,final ExecutionGraph executionGraph,final ExecutionGroupVertex groupVertex,final RuntimeEnvironment environment){
  this.vertexID=vertexID;
  this.invokableClass=invokableClass;
  this.executionGraph=executionGraph;
  this.groupVertex=groupVertex;
  this.environment=environment;
  this.retriesLeft=new AtomicInteger(groupVertex.getNumberOfExecutionRetries());
  registerExecutionListener(this.executionGraph);
}
Program: 55512
Project: 55512
Buggy source:
/** 
 * Returns a duplicate of this execution vertex.
 * @param preserveVertexID <code>true</code> to copy the vertex's ID to the duplicated vertex, <code>false</code> to create a new ID
 * @return a duplicate of this execution vertex
 * @throws Exception any exception that might be thrown by the user code during instantiation and registration of input and output channels
 */
public ExecutionVertex duplicateVertex(final boolean preserveVertexID) throws Exception {
  ExecutionVertexID newVertexID;
  if (preserveVertexID) {
    newVertexID=this.vertexID;
  }
 else {
    newVertexID=new ExecutionVertexID();
  }
  final RuntimeEnvironment duplicatedEnvironment=this.environment.duplicateEnvironment();
  final ExecutionVertex duplicatedVertex=new ExecutionVertex(newVertexID,this.invokableClass,this.executionGraph,this.groupVertex,duplicatedEnvironment);
  duplicatedVertex.setAllocatedResource(this.allocatedResource);
  return duplicatedVertex;
}

Fixed version (ground truth):
/** 
 * Returns a duplicate of this execution vertex.
 * @param preserveVertexID <code>true</code> to copy the vertex's ID to the duplicated vertex, <code>false</code> to create a new ID
 * @return a duplicate of this execution vertex
 * @throws Exception any exception that might be thrown by the user code during instantiation and registration of input and output channels
 */
public ExecutionVertex duplicateVertex(final boolean preserveVertexID) throws Exception {
  ExecutionVertexID newVertexID;
  if (preserveVertexID) {
    newVertexID=this.vertexID;
  }
 else {
    newVertexID=new ExecutionVertexID();
  }
  final RuntimeEnvironment duplicatedEnvironment=this.environment.duplicateEnvironment();
  final ExecutionVertex duplicatedVertex=new ExecutionVertex(newVertexID,this.invokableClass,this.executionGraph,this.groupVertex,duplicatedEnvironment);
  duplicatedVertex.checkpointState.set(this.checkpointState.get());
  duplicatedVertex.setAllocatedResource(this.allocatedResource);
  return duplicatedVertex;
}
Program: 55515
Project: 55515
Buggy source:
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{ServerTestUtils.getConfigDir(),new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{ServerTestUtils.getConfigDir(),new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      Thread.sleep(10000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}
Program: 55516
Project: 55516
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean equals(final Object obj){
  if (!(obj instanceof AbstractJobResult)) {
    return false;
  }
  final AbstractJobResult ajr=(AbstractJobResult)obj;
  if (this.returnCode == null) {
    if (ajr.getReturnCode() != null) {
      return false;
    }
  }
 else {
    if (!this.returnCode.equals(ajr.getReturnCode())) {
      return false;
    }
  }
  if (this.description == null) {
    if (this.description != null) {
      return false;
    }
  }
 else {
    if (!this.description.equals(ajr.getDescription())) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean equals(final Object obj){
  if (!(obj instanceof AbstractJobResult)) {
    return false;
  }
  final AbstractJobResult ajr=(AbstractJobResult)obj;
  if (this.returnCode == null) {
    if (ajr.getReturnCode() != null) {
      return false;
    }
  }
 else {
    if (!this.returnCode.equals(ajr.getReturnCode())) {
      return false;
    }
  }
  if (this.description == null) {
  }
 else {
    if (!this.description.equals(ajr.getDescription())) {
      return false;
    }
  }
  return true;
}
Program: 55517
Project: 55517
Buggy source:
/** 
 * Returns the next code point at the current position in the buffer. The buffer's position will be incremented. Any mark set on this buffer will be changed by this method!
 */
public static int bytesToCodePoint(final ByteBuffer bytes){
  bytes.mark();
  final byte b=bytes.get();
  bytes.reset();
  final int extraBytesToRead=bytesFromUTF8[(b & 0xFF)];
  if (extraBytesToRead < 0) {
    return -1;
  }
  int ch=0;
switch (extraBytesToRead) {
case 5:
    ch+=(bytes.get() & 0xFF);
  ch<<=6;
case 4:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 3:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 2:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 1:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 0:
ch+=(bytes.get() & 0xFF);
}
ch-=offsetsFromUTF8[extraBytesToRead];
return ch;
}

Fixed version (ground truth):
/** 
 * Returns the next code point at the current position in the buffer. The buffer's position will be incremented. Any mark set on this buffer will be changed by this method!
 */
public static int bytesToCodePoint(final ByteBuffer bytes){
  bytes.mark();
  final byte b=bytes.get();
  bytes.reset();
  final int extraBytesToRead=bytesFromUTF8[(b & 0xFF)];
  if (extraBytesToRead < 0) {
    return -1;
  }
  int ch=0;
switch (extraBytesToRead) {
case 5:
    ch+=(bytes.get() & 0xFF);
  ch<<=6;
case 4:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 3:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 2:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 1:
ch+=(bytes.get() & 0xFF);
ch<<=6;
case 0:
ch+=(bytes.get() & 0xFF);
default :
break;
}
ch-=offsetsFromUTF8[extraBytesToRead];
return ch;
}
Program: 55519
Project: 55519
Buggy source:
/** 
 * Reads a hard-coded tree topology from file and creates a tree according to the hard-coded topology from the file.
 * @param nodes
 * @return
 */
private MulticastForwardingTable createHardCodedTree(LinkedList<TreeNode> nodes){
  try {
    FileInputStream fstream=new FileInputStream(this.hardcodedtreefilepath);
    DataInputStream in=new DataInputStream(fstream);
    BufferedReader br=new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine=br.readLine()) != null) {
      String[] values=strLine.split("String_Node_Str");
      String actualhostname=values[0];
      for (      TreeNode n : nodes) {
        if (n.toString().equals(actualhostname)) {
          for (int i=1; i < values.length; i++) {
            for (            TreeNode childnode : nodes) {
              if (childnode.toString().equals(values[i])) {
                n.addChild(childnode);
              }
            }
          }
        }
      }
    }
    return nodes.getFirst().createForwardingTable();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Reads a hard-coded tree topology from file and creates a tree according to the hard-coded topology from the file.
 * @param nodes
 * @return
 */
private MulticastForwardingTable createHardCodedTree(LinkedList<TreeNode> nodes){
  try {
    FileInputStream fstream=new FileInputStream(this.hardcodedtreefilepath);
    DataInputStream in=new DataInputStream(fstream);
    BufferedReader br=new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine=br.readLine()) != null) {
      String[] values=strLine.split("String_Node_Str");
      String actualhostname=values[0];
      for (      TreeNode n : nodes) {
        if (n.toString().equals(actualhostname)) {
          for (int i=1; i < values.length; i++) {
            for (            TreeNode childnode : nodes) {
              if (childnode.toString().equals(values[i])) {
                n.addChild(childnode);
              }
            }
          }
        }
      }
    }
    br.close();
    return nodes.getFirst().createForwardingTable();
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return null;
  }
}
Program: 55520
Project: 55520
Buggy source:
/** 
 * Auxiliary method that reads penalties for tree nodes from the given file. Expects penalties in format <HOSTNAME> <PENALTY_AS_INTEGER> and saves the penalty value in the corresponding TreeNode objects within the provided list.
 * @param f
 * @param nodes List with the nodes
 */
private void readPenalitesFromFile(File f,List<TreeNode> nodes){
  try {
    FileInputStream fstream=new FileInputStream(f);
    DataInputStream in=new DataInputStream(fstream);
    BufferedReader br=new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine=br.readLine()) != null) {
      String[] values=strLine.split("String_Node_Str");
      String actualhostname=values[0];
      int actualpenalty=Integer.valueOf(values[1]);
      for (      TreeNode n : nodes) {
        if (n.toString().equals(actualhostname)) {
          System.out.println("String_Node_Str" + n.toString() + "String_Node_Str"+ actualpenalty);
          n.setProperty("String_Node_Str",actualpenalty);
        }
      }
    }
    in.close();
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Auxiliary method that reads penalties for tree nodes from the given file. Expects penalties in format <HOSTNAME> <PENALTY_AS_INTEGER> and saves the penalty value in the corresponding TreeNode objects within the provided list.
 * @param f
 * @param nodes List with the nodes
 */
private void readPenalitesFromFile(File f,List<TreeNode> nodes){
  try {
    FileInputStream fstream=new FileInputStream(f);
    DataInputStream in=new DataInputStream(fstream);
    BufferedReader br=new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine=br.readLine()) != null) {
      String[] values=strLine.split("String_Node_Str");
      String actualhostname=values[0];
      int actualpenalty=Integer.valueOf(values[1]);
      for (      TreeNode n : nodes) {
        if (n.toString().equals(actualhostname)) {
          System.out.println("String_Node_Str" + n.toString() + "String_Node_Str"+ actualpenalty);
          n.setProperty("String_Node_Str",actualpenalty);
        }
      }
    }
    br.close();
    in.close();
    fstream.close();
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str" + e.getMessage());
  }
}
Program: 55521
Project: 55521
Buggy source:
private boolean isRestartRequested(){
  if (this.restartRequested.compareAndSet(true,false)) {
    if (!this.interruptCalled.compareAndSet(true,false)) {
      while (!Thread.currentThread().isInterrupted()) {
      }
      this.interruptCalled.set(false);
    }
    Thread.interrupted();
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean isRestartRequested(){
  if (this.restartRequested.compareAndSet(true,false)) {
    if (!this.interruptCalled.compareAndSet(true,false)) {
      try {
        Thread.sleep(10L);
      }
 catch (      InterruptedException e) {
      }
      this.interruptCalled.set(false);
    }
    Thread.interrupted();
    return true;
  }
  return false;
}
Program: 55523
Project: 55523
Buggy source:
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      final String userDir=System.getProperty("String_Node_Str");
      String configDir=userDir + File.separator + CONFIGURATION_DIRECTORY;
      if (!new File(configDir).exists()) {
        configDir=userDir + "String_Node_Str" + CONFIGURATION_DIRECTORY;
      }
      final Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{configDir,new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      final String userDir=System.getProperty("String_Node_Str");
      String configDir=userDir + File.separator + CONFIGURATION_DIRECTORY;
      if (!new File(configDir).exists()) {
        configDir=userDir + "String_Node_Str" + CONFIGURATION_DIRECTORY;
      }
      final Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{configDir,new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      ServerTestUtils.waitForJobManagerToBecomeReady(jobManager);
    }
 catch (    Exception e) {
      fail(StringUtils.stringifyException(e));
    }
  }
}
Program: 55524
Project: 55524
Buggy source:
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{ServerTestUtils.getConfigDir(),new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      Thread.sleep(10000);
    }
 catch (    InterruptedException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets up Nephele in local mode.
 */
@BeforeClass public static void startNephele(){
  if (jobManagerThread == null) {
    JobManager jobManager=null;
    try {
      Constructor<JobManager> c=JobManager.class.getDeclaredConstructor(new Class[]{String.class,String.class});
      c.setAccessible(true);
      jobManager=c.newInstance(new Object[]{ServerTestUtils.getConfigDir(),new String("String_Node_Str")});
    }
 catch (    SecurityException e) {
      fail(e.getMessage());
    }
catch (    NoSuchMethodException e) {
      fail(e.getMessage());
    }
catch (    IllegalArgumentException e) {
      fail(e.getMessage());
    }
catch (    InstantiationException e) {
      fail(e.getMessage());
    }
catch (    IllegalAccessException e) {
      fail(e.getMessage());
    }
catch (    InvocationTargetException e) {
      fail(e.getMessage());
    }
    configuration=GlobalConfiguration.getConfiguration(new String[]{ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY});
    if (jobManager != null) {
      jobManagerThread=new JobManagerThread(jobManager);
      jobManagerThread.start();
    }
    try {
      ServerTestUtils.waitForJobManagerToBecomeReady(jobManager);
    }
 catch (    Exception e) {
      fail(StringUtils.stringifyException(e));
    }
  }
}
Program: 55525
Project: 55525
Buggy source:
void restart(){
  changeExecutionState(ExecutionState.STARTING,null);
  this.restartRequested.set(true);
  interrupt();
}

Fixed version (ground truth):
void restart(){
  changeExecutionState(ExecutionState.STARTING,null);
  this.restartRequested.set(true);
  interrupt();
  this.interruptCalled.set(true);
}
Program: 55526
Project: 55526
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  while (true) {
    changeExecutionState(ExecutionState.REPLAYING,null);
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
      return;
    }
    resetAllOutputBroker();
    try {
      replayCheckpoint();
      if (this.executionObserver.isCanceled()) {
        throw new InterruptedException();
      }
    }
 catch (    Exception e) {
      if (this.restartRequested.compareAndSet(true,false)) {
        while (!Thread.currentThread().isInterrupted()) {
        }
        Thread.interrupted();
        continue;
      }
      if (this.executionObserver.isCanceled()) {
        changeExecutionState(ExecutionState.CANCELED,null);
      }
 else {
        changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
      }
      return;
    }
    if (this.restartRequested.compareAndSet(true,false)) {
      while (!Thread.currentThread().isInterrupted()) {
      }
      Thread.interrupted();
      continue;
    }
    break;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  while (true) {
    changeExecutionState(ExecutionState.REPLAYING,null);
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
      return;
    }
    resetAllOutputBroker();
    try {
      replayCheckpoint();
      if (this.executionObserver.isCanceled()) {
        throw new InterruptedException();
      }
    }
 catch (    Exception e) {
      if (isRestartRequested()) {
        continue;
      }
      if (this.executionObserver.isCanceled()) {
        changeExecutionState(ExecutionState.CANCELED,null);
      }
 else {
        changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
      }
      return;
    }
    if (isRestartRequested()) {
      continue;
    }
    break;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}
Program: 55527
Project: 55527
Buggy source:
void restart(){
  this.restartRequested.set(true);
}

Fixed version (ground truth):
void restart(){
  changeExecutionState(ExecutionState.STARTING,null);
  this.restartRequested.set(true);
  interrupt();
}
Program: 55529
Project: 55529
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  changeExecutionState(ExecutionState.REPLAYING,null);
  if (this.executionObserver.isCanceled()) {
    changeExecutionState(ExecutionState.CANCELED,null);
    return;
  }
  try {
    replayCheckpoint();
    if (this.executionObserver.isCanceled()) {
      throw new InterruptedException();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void run(){
  while (true) {
    changeExecutionState(ExecutionState.REPLAYING,null);
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
      return;
    }
    resetAllOutputBroker();
    try {
      replayCheckpoint();
      if (this.executionObserver.isCanceled()) {
        throw new InterruptedException();
      }
    }
 catch (    Exception e) {
      if (this.restartRequested.compareAndSet(true,false)) {
        while (!Thread.currentThread().isInterrupted()) {
        }
        Thread.interrupted();
        continue;
      }
      if (this.executionObserver.isCanceled()) {
        changeExecutionState(ExecutionState.CANCELED,null);
      }
 else {
        changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
      }
      return;
    }
    if (this.restartRequested.compareAndSet(true,false)) {
      while (!Thread.currentThread().isInterrupted()) {
      }
      Thread.interrupted();
      continue;
    }
    break;
  }
  changeExecutionState(ExecutionState.FINISHING,null);
  try {
    waitForAllOutputBrokerToFinish();
  }
 catch (  Exception e) {
    if (this.executionObserver.isCanceled()) {
      changeExecutionState(ExecutionState.CANCELED,null);
    }
 else {
      changeExecutionState(ExecutionState.FAILED,StringUtils.stringifyException(e));
    }
    return;
  }
  changeExecutionState(ExecutionState.FINISHED,null);
}
Program: 55531
Project: 55531
Buggy source:
/** 
 * Constructs a new ephemeral checkpoint.
 * @param task the task this checkpoint belongs to
 * @param ephemeral <code>true</code> if the checkpoint is initially ephemeral, <code>false</code> if the checkpoint shall be persistent from the beginning
 */
public EphemeralCheckpoint(final RuntimeTask task,final boolean ephemeral){
  this.task=task;
  int nooc=0;
  final RuntimeEnvironment environment=task.getRuntimeEnvironment();
  for (int i=0; i < environment.getNumberOfOutputGates(); ++i) {
    nooc+=environment.getOutputGate(i).getNumberOfOutputChannels();
  }
  this.numberOfConnectedChannels=nooc;
  this.checkpointingDecision=(ephemeral ? CheckpointingDecisionState.UNDECIDED : CheckpointingDecisionState.CHECKPOINTING);
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + task.getVertexID() + "String_Node_Str"+ this.checkpointingDecision);
  }
  if (this.checkpointingDecision == CheckpointingDecisionState.CHECKPOINTING) {
    this.task.checkpointStateChanged(CheckpointState.PARTIAL);
    this.writeThread=new WriteThread(FileBufferManager.getInstance(),this.task.getVertexID(),this.numberOfConnectedChannels);
  }
}

Fixed version (ground truth):
/** 
 * Constructs a new ephemeral checkpoint.
 * @param task the task this checkpoint belongs to
 * @param ephemeral <code>true</code> if the checkpoint is initially ephemeral, <code>false</code> if the checkpoint shall be persistent from the beginning
 */
public EphemeralCheckpoint(final RuntimeTask task,final boolean ephemeral){
  this.task=task;
  int nooc=0;
  final RuntimeEnvironment environment=task.getRuntimeEnvironment();
  for (int i=0; i < environment.getNumberOfOutputGates(); ++i) {
    nooc+=environment.getOutputGate(i).getNumberOfOutputChannels();
  }
  this.numberOfConnectedChannels=nooc;
  this.checkpointingDecision=(ephemeral ? CheckpointingDecisionState.UNDECIDED : CheckpointingDecisionState.CHECKPOINTING);
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + task.getVertexID() + "String_Node_Str"+ this.checkpointingDecision);
  }
  if (this.checkpointingDecision == CheckpointingDecisionState.CHECKPOINTING) {
    this.task.checkpointStateChanged(CheckpointState.PARTIAL);
    this.writeThread=new WriteThread(FileBufferManager.getInstance(),this.task.getVertexID(),this.numberOfConnectedChannels);
    this.writeThread.start();
  }
}
Program: 55532
Project: 55532
Buggy source:
public EphemeralCheckpointForwarder(final EphemeralCheckpoint ephemeralCheckpoint,final AbstractOutputChannelForwarder next){
  super(next);
  if (next == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.ephemeralCheckpoint=ephemeralCheckpoint;
}

Fixed version (ground truth):
public EphemeralCheckpointForwarder(final EphemeralCheckpoint ephemeralCheckpoint,final AbstractOutputChannelForwarder next){
  super(next);
  this.ephemeralCheckpoint=ephemeralCheckpoint;
}
Program: 55533
Project: 55533
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean hasDataLeft() throws IOException, InterruptedException {
  if (this.ephemeralCheckpoint.hasDataLeft()) {
    return true;
  }
  return getNext().hasDataLeft();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean hasDataLeft() throws IOException, InterruptedException {
  if (this.ephemeralCheckpoint.hasDataLeft()) {
    return true;
  }
  final AbstractOutputChannelForwarder next=getNext();
  if (next != null) {
    return getNext().hasDataLeft();
  }
  return false;
}
Program: 55534
Project: 55534
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void push(final TransferEnvelope transferEnvelope) throws IOException, InterruptedException {
  this.ephemeralCheckpoint.forward(transferEnvelope);
  getNext().push(transferEnvelope);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void push(final TransferEnvelope transferEnvelope) throws IOException, InterruptedException {
  this.ephemeralCheckpoint.forward(transferEnvelope);
  final AbstractOutputChannelForwarder next=getNext();
  if (next != null) {
    next.push(transferEnvelope);
  }
 else {
    recycleTransferEnvelope(transferEnvelope);
  }
}
Program: 55535
Project: 55535
Buggy source:
/** 
 * Constructs a new replay input channel context.
 * @param encapsulatedContext the encapsulated input channel context
 */
ReplayInputChannelContext(final InputChannelContext encapsulatedContext){
  this.encapsulatedContext=encapsulatedContext;
}

Fixed version (ground truth):
/** 
 * Constructs a new replay input channel context.
 * @param channelID the ID of the input channel this context belongs to
 * @param encapsulatedContext the encapsulated input channel context
 */
ReplayInputChannelContext(final ChannelID channelID,final InputChannelContext encapsulatedContext){
  this.channelID=channelID;
  this.encapsulatedContext=encapsulatedContext;
}
Program: 55536
Project: 55536
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public ChannelID getChannelID(){
  return this.encapsulatedContext.getChannelID();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public ChannelID getChannelID(){
  return this.channelID;
}
Program: 55537
Project: 55537
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void destroy(){
  this.encapsulatedContext.destroy();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void destroy(){
  if (this.encapsulatedContext != null) {
    this.encapsulatedContext.destroy();
  }
}
Program: 55538
Project: 55538
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public InputChannelContext createInputChannelContext(ChannelID channelID,InputChannelContext previousContext){
  return new ReplayInputChannelContext(previousContext);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public InputChannelContext createInputChannelContext(final ChannelID channelID,final InputChannelContext previousContext){
  return new ReplayInputChannelContext(channelID,previousContext);
}
Program: 55539
Project: 55539
Buggy source:
private static ExecutionState determineOverallExecutionState(final ExecutionState unchangedExecutionState,final ExecutionState changedExecutionState){
  if (changedExecutionState == null) {
    return changedExecutionState;
  }
  if (changedExecutionState == ExecutionState.REPLAYING) {
    if (unchangedExecutionState == ExecutionState.RUNNING || unchangedExecutionState == ExecutionState.FINISHING) {
      return ExecutionState.REPLAYING;
    }
 else {
      return unchangedExecutionState;
    }
  }
  if (changedExecutionState == ExecutionState.CANCELING) {
    return ExecutionState.CANCELING;
  }
  if (changedExecutionState == ExecutionState.CANCELED && unchangedExecutionState == ExecutionState.CANCELED) {
    return ExecutionState.CANCELED;
  }
  if (changedExecutionState == ExecutionState.FINISHING && (unchangedExecutionState == ExecutionState.FINISHING || unchangedExecutionState == ExecutionState.FINISHED)) {
    return ExecutionState.FINISHING;
  }
  if (changedExecutionState == ExecutionState.FINISHED && unchangedExecutionState == ExecutionState.FINISHED) {
    return ExecutionState.FINISHED;
  }
  if (changedExecutionState == ExecutionState.FAILED && unchangedExecutionState == ExecutionState.FAILED) {
    return ExecutionState.FAILED;
  }
  return null;
}

Fixed version (ground truth):
private static ExecutionState determineOverallExecutionState(final ExecutionState unchangedExecutionState,final ExecutionState changedExecutionState){
  if (unchangedExecutionState == null) {
    return changedExecutionState;
  }
  if (changedExecutionState == ExecutionState.REPLAYING) {
    if (unchangedExecutionState == ExecutionState.RUNNING || unchangedExecutionState == ExecutionState.FINISHING) {
      return ExecutionState.REPLAYING;
    }
 else {
      return unchangedExecutionState;
    }
  }
  if (changedExecutionState == ExecutionState.CANCELING) {
    return ExecutionState.CANCELING;
  }
  if (changedExecutionState == ExecutionState.CANCELED && unchangedExecutionState == ExecutionState.CANCELED) {
    return ExecutionState.CANCELED;
  }
  if (changedExecutionState == ExecutionState.FINISHING && (unchangedExecutionState == ExecutionState.FINISHING || unchangedExecutionState == ExecutionState.FINISHED)) {
    return ExecutionState.FINISHING;
  }
  if (changedExecutionState == ExecutionState.FINISHED && unchangedExecutionState == ExecutionState.FINISHED) {
    return ExecutionState.FINISHED;
  }
  if (changedExecutionState == ExecutionState.FAILED && unchangedExecutionState == ExecutionState.FAILED) {
    return ExecutionState.FAILED;
  }
  return null;
}