Source:
protected synchronized void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) { while (streamEventChunk.hasNext()) { flag = false; StreamEvent streamEvent = streamEventChunk.next(); long currentTime = executionPlanContext.getTimestampGenerator().currentTime(); StreamEvent clonedEvent = null; if (streamEvent.getType() == StreamEvent.Type.CURRENT) { clonedEvent = streamEventCloner.copyStreamEvent(streamEvent); clonedEvent.setType(StreamEvent.Type.EXPIRED); clonedEvent.setTimestamp(currentTime + timeInMilliSeconds); } boolean eventScheduled = false; while (expiredEventChunk.hasNext()) { StreamEvent expiredEvent = expiredEventChunk.next(); long timeDiff = expiredEvent.getTimestamp() - currentTime; if (timeDiff <= 0) { expiredEventChunk.remove(); count--; streamEventChunk.insertBeforeCurrent(expiredEvent); flag = true; } else { scheduler.notifyAt(expiredEvent.getTimestamp()); expiredEventChunk.reset(); eventScheduled = true; break; } } expiredEventChunk.reset(); if (streamEvent.getType() == StreamEvent.Type.CURRENT) { if (count < length) { count++; this.expiredEventChunk.add(clonedEvent); } else { StreamEvent firstEvent = this.expiredEventChunk.poll(); if (firstEvent != null) { if(!flag) { streamEventChunk.insertBeforeCurrent(firstEvent); flag = true; } this.expiredEventChunk.add(clonedEvent); } else if(!flag) { streamEventChunk.insertBeforeCurrent(clonedEvent); flag = true; } } } if (!eventScheduled) { if(clonedEvent != null){ scheduler.notifyAt(clonedEvent.getTimestamp()); } } } expiredEventChunk.reset(); nextProcessor.process(streamEventChunk); }

Target:
protected synchronized void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) { boolean flag; while (streamEventChunk.hasNext()) { flag = false; StreamEvent streamEvent = streamEventChunk.next(); long currentTime = executionPlanContext.getTimestampGenerator().currentTime(); StreamEvent clonedEvent = null; if (streamEvent.getType() == StreamEvent.Type.CURRENT) { clonedEvent = streamEventCloner.copyStreamEvent(streamEvent); clonedEvent.setType(StreamEvent.Type.EXPIRED); clonedEvent.setTimestamp(currentTime + timeInMilliSeconds); } boolean eventScheduled = false; while (expiredEventChunk.hasNext()) { StreamEvent expiredEvent = expiredEventChunk.next(); long timeDiff = expiredEvent.getTimestamp() - currentTime; if (timeDiff <= 0) { expiredEventChunk.remove(); count--; streamEventChunk.insertBeforeCurrent(expiredEvent); flag = true; } else { scheduler.notifyAt(expiredEvent.getTimestamp()); expiredEventChunk.reset(); eventScheduled = true; break; } } expiredEventChunk.reset(); if (streamEvent.getType() == StreamEvent.Type.CURRENT) { if (count < length) { count++; this.expiredEventChunk.add(clonedEvent); } else { StreamEvent firstEvent = this.expiredEventChunk.poll(); if (firstEvent != null) { if(!flag) { streamEventChunk.insertBeforeCurrent(firstEvent); flag = true; } this.expiredEventChunk.add(clonedEvent); } else if(!flag) { streamEventChunk.insertBeforeCurrent(clonedEvent); flag = true; } } } if (!eventScheduled) { if(clonedEvent != null){ scheduler.notifyAt(clonedEvent.getTimestamp()); } } } expiredEventChunk.reset(); nextProcessor.process(streamEventChunk); }