Program: 5106
Project: 5106
Buggy source:
/** 
 * This method is used to generate the logs for program which are used for testing. Single call to this method would add   {@link #MAX} number of events.First 20 events are generated without  {@link ApplicationLoggingContext#TAG_RUN_ID} tag.For next 40 events, alternate event is tagged with  {@code ApplicationLoggingContext#TAG_RUN_ID}. Last 20 events are not tagged with   {@code ApplicationLoggingContext#TAG_RUN_ID}. All events are alternately marked as   {@link Level#ERROR} and {@link Level#WARN}. All events are alternately tagged with "plugin", "program" and "system" as value of MDC property ".origin" All events are alternately tagged with "lifecycle" as value of MDC property "MDC:eventType
 */
private void generateLogs(LoggingContext loggingContext,ProgramId programId,ProgramRunStatus runStatus) throws InterruptedException {
  String[] origins={"String_Node_Str","String_Node_Str","String_Node_Str"};
  String entityId=LoggingContextHelper.getEntityId(loggingContext).getValue();
  RunId runId=null;
  Long stopTs=null;
  for (int i=0; i < MAX; ++i) {
    if (i == 20) {
      runId=RunIds.generate(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    }
 else     if (i == 60 && runStatus != ProgramRunStatus.RUNNING && runStatus != ProgramRunStatus.SUSPENDED) {
      stopTs=getMockTimeSecs(i);
    }
    LoggingEvent event=new LoggingEvent("String_Node_Str",(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME),i % 2 == 0 ? Level.ERROR : Level.WARN,entityId + "String_Node_Str" + i,null,null);
    event.setTimeStamp(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    Map<String,String> tagMap=Maps.newHashMap(Maps.transformValues(loggingContext.getSystemTagsMap(),TAG_TO_STRING_FUNCTION));
    if (runId != null && stopTs == null && i % 2 == 0) {
      tagMap.put(ApplicationLoggingContext.TAG_RUN_ID,runId.getId());
    }
    tagMap.put("String_Node_Str",origins[i % 3]);
    if (i % 2 == 0) {
      tagMap.put("String_Node_Str","String_Node_Str");
    }
    event.setMDCPropertyMap(tagMap);
    logEvents.add(new LogEvent(event,new LogOffset(i,i)));
  }
  long startTs=RunIds.getTime(runId,TimeUnit.SECONDS);
  if (programId != null) {
    runRecordMap.put(programId,new RunRecord(runId.getId(),startTs,stopTs,runStatus,null));
    store.setStart(programId,runId.getId(),startTs);
    if (stopTs != null) {
      store.setStop(programId,runId.getId(),stopTs,runStatus);
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is used to generate the logs for program which are used for testing. Single call to this method would add   {@link #MAX} number of events.First 20 events are generated without  {@link ApplicationLoggingContext#TAG_RUN_ID} tag.For next 40 events, alternate event is tagged with  {@code ApplicationLoggingContext#TAG_RUN_ID}. Last 20 events are not tagged with   {@code ApplicationLoggingContext#TAG_RUN_ID}. All events are alternately marked as   {@link Level#ERROR} and {@link Level#WARN}. All events are alternately tagged with "plugin", "program" and "system" as value of MDC property ".origin" All events are alternately tagged with "lifecycle" as value of MDC property "MDC:eventType
 */
private void generateLogs(LoggingContext loggingContext,ProgramId programId,ProgramRunStatus runStatus) throws InterruptedException {
  String[] origins={"String_Node_Str","String_Node_Str","String_Node_Str"};
  String entityId=LoggingContextHelper.getEntityId(loggingContext).getValue();
  StackTraceElement stackTraceElementNative=new StackTraceElement("String_Node_Str","String_Node_Str",null,-2);
  RunId runId=null;
  Long stopTs=null;
  for (int i=0; i < MAX; ++i) {
    if (i == 20) {
      runId=RunIds.generate(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    }
 else     if (i == 60 && runStatus != ProgramRunStatus.RUNNING && runStatus != ProgramRunStatus.SUSPENDED) {
      stopTs=getMockTimeSecs(i);
    }
    LoggingEvent event=new LoggingEvent("String_Node_Str",(ch.qos.logback.classic.Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME),i % 2 == 0 ? Level.ERROR : Level.WARN,entityId + "String_Node_Str" + i,null,null);
    event.setTimeStamp(TimeUnit.SECONDS.toMillis(getMockTimeSecs(i)));
    Map<String,String> tagMap=Maps.newHashMap(Maps.transformValues(loggingContext.getSystemTagsMap(),TAG_TO_STRING_FUNCTION));
    if (runId != null && stopTs == null && i % 2 == 0) {
      tagMap.put(ApplicationLoggingContext.TAG_RUN_ID,runId.getId());
    }
    tagMap.put("String_Node_Str",origins[i % 3]);
    if (i % 2 == 0) {
      tagMap.put("String_Node_Str","String_Node_Str");
    }
    if (i == 30) {
      event.setCallerData(new StackTraceElement[]{stackTraceElementNative});
    }
    event.setMDCPropertyMap(tagMap);
    logEvents.add(new LogEvent(event,new LogOffset(i,i)));
  }
  long startTs=RunIds.getTime(runId,TimeUnit.SECONDS);
  if (programId != null) {
    runRecordMap.put(programId,new RunRecord(runId.getId(),startTs,stopTs,runStatus,null));
    store.setStart(programId,runId.getId(),startTs);
    if (stopTs != null) {
      store.setStop(programId,runId.getId(),stopTs,runStatus);
    }
  }
}