Program: 29045
Project: 29045
Buggy source:
@Override protected void process(ComplexEventChunk<StreamEvent> streamEventChunk,Processor nextProcessor,StreamEventCloner streamEventCloner){
synchronized (this) {
    if (nextEmitTime == -1) {
      long currentTime=executionPlanContext.getTimestampGenerator().currentTime();
      if (isStartTimeEnabled) {
        nextEmitTime=getNextEmitTime(currentTime) + timeInMilliSeconds;
      }
 else {
        nextEmitTime=executionPlanContext.getTimestampGenerator().currentTime();
      }
      scheduler.notifyAt(nextEmitTime);
    }
    long currentTime=executionPlanContext.getTimestampGenerator().currentTime();
    boolean sendEvents;
    if (currentTime >= nextEmitTime) {
      nextEmitTime+=timeInMilliSeconds;
      if (currentEventChunk.getFirst() != null || expiredEventChunk.getFirst() != null) {
        scheduler.notifyAt(nextEmitTime);
      }
      sendEvents=true;
    }
 else {
      sendEvents=false;
    }
    while (streamEventChunk.hasNext()) {
      StreamEvent streamEvent=streamEventChunk.next();
      if (streamEvent.getType() != ComplexEvent.Type.CURRENT) {
        continue;
      }
      StreamEvent clonedStreamEvent=streamEventCloner.copyStreamEvent(streamEvent);
      currentEventChunk.add(clonedStreamEvent);
    }
    streamEventChunk.clear();
    if (sendEvents) {
      currentEventChunk.reset();
      while (expiredEventChunk.hasNext()) {
        StreamEvent expiredEvent=expiredEventChunk.next();
        expiredEvent.setTimestamp(currentTime);
      }
      if (expiredEventChunk.getFirst() != null) {
        streamEventChunk.add(expiredEventChunk.getFirst());
      }
      expiredEventChunk.clear();
      while (currentEventChunk.hasNext()) {
        StreamEvent currentEvent=currentEventChunk.next();
        StreamEvent toExpireEvent=streamEventCloner.copyStreamEvent(currentEvent);
        toExpireEvent.setType(StreamEvent.Type.EXPIRED);
        expiredEventChunk.add(toExpireEvent);
      }
      if (currentEventChunk.getFirst() != null) {
        streamEventChunk.add(currentEventChunk.getFirst());
      }
      currentEventChunk.clear();
    }
  }
  if (streamEventChunk.getFirst() != null) {
    nextProcessor.process(streamEventChunk);
  }
}

Fixed version (ground truth):
@Override protected void process(ComplexEventChunk<StreamEvent> streamEventChunk,Processor nextProcessor,StreamEventCloner streamEventCloner){
synchronized (this) {
    if (nextEmitTime == -1) {
      long currentTime=executionPlanContext.getTimestampGenerator().currentTime();
      if (isStartTimeEnabled) {
        nextEmitTime=getNextEmitTime(currentTime);
      }
 else {
        nextEmitTime=executionPlanContext.getTimestampGenerator().currentTime() + timeInMilliSeconds;
      }
      scheduler.notifyAt(nextEmitTime);
    }
    long currentTime=executionPlanContext.getTimestampGenerator().currentTime();
    boolean sendEvents;
    if (currentTime >= nextEmitTime) {
      nextEmitTime+=timeInMilliSeconds;
      if (currentEventChunk.getFirst() != null || expiredEventChunk.getFirst() != null) {
        scheduler.notifyAt(nextEmitTime);
      }
      sendEvents=true;
    }
 else {
      sendEvents=false;
    }
    while (streamEventChunk.hasNext()) {
      StreamEvent streamEvent=streamEventChunk.next();
      if (streamEvent.getType() != ComplexEvent.Type.CURRENT) {
        continue;
      }
      StreamEvent clonedStreamEvent=streamEventCloner.copyStreamEvent(streamEvent);
      currentEventChunk.add(clonedStreamEvent);
    }
    streamEventChunk.clear();
    if (sendEvents) {
      currentEventChunk.reset();
      while (expiredEventChunk.hasNext()) {
        StreamEvent expiredEvent=expiredEventChunk.next();
        expiredEvent.setTimestamp(currentTime);
      }
      if (expiredEventChunk.getFirst() != null) {
        streamEventChunk.add(expiredEventChunk.getFirst());
      }
      expiredEventChunk.clear();
      while (currentEventChunk.hasNext()) {
        StreamEvent currentEvent=currentEventChunk.next();
        StreamEvent toExpireEvent=streamEventCloner.copyStreamEvent(currentEvent);
        toExpireEvent.setType(StreamEvent.Type.EXPIRED);
        expiredEventChunk.add(toExpireEvent);
      }
      if (currentEventChunk.getFirst() != null) {
        streamEventChunk.add(currentEventChunk.getFirst());
      }
      currentEventChunk.clear();
    }
  }
  if (streamEventChunk.getFirst() != null) {
    nextProcessor.process(streamEventChunk);
  }
}