Program: 29017
Project: 29017
Buggy source:
public static StreamRuntime parseInputStream(JoinInputStream joinInputStream,ExecutionPlanContext executionPlanContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,EventTable> eventTableMap,List<VariableExpressionExecutor> executors,LatencyTracker latencyTracker,boolean outputExpectsExpiredEvents){
  ProcessStreamReceiver leftProcessStreamReceiver;
  ProcessStreamReceiver rightProcessStreamReceiver;
  MetaStreamEvent leftMetaStreamEvent=new MetaStreamEvent();
  MetaStreamEvent rightMetaStreamEvent=new MetaStreamEvent();
  String leftInputStreamId=((SingleInputStream)joinInputStream.getLeftInputStream()).getStreamId();
  String rightInputStreamId=((SingleInputStream)joinInputStream.getRightInputStream()).getStreamId();
  boolean leftOuterJoinProcessor=false;
  boolean rightOuterJoinProcessor=false;
  if (joinInputStream.getAllStreamIds().size() == 2) {
    if (!streamDefinitionMap.containsKey(leftInputStreamId)) {
      leftMetaStreamEvent.setTableEvent(true);
    }
    if (!streamDefinitionMap.containsKey(rightInputStreamId)) {
      rightMetaStreamEvent.setTableEvent(true);
    }
    leftProcessStreamReceiver=new ProcessStreamReceiver(leftInputStreamId,latencyTracker);
    rightProcessStreamReceiver=new ProcessStreamReceiver(rightInputStreamId,latencyTracker);
    if (leftMetaStreamEvent.isTableEvent() && rightMetaStreamEvent.isTableEvent()) {
      throw new ExecutionPlanCreationException("String_Node_Str" + leftInputStreamId + "String_Node_Str"+ rightInputStreamId);
    }
  }
 else {
    if (streamDefinitionMap.containsKey(joinInputStream.getAllStreamIds().get(0))) {
      String defaultLockKey="String_Node_Str";
      rightProcessStreamReceiver=new MultiProcessStreamReceiver(joinInputStream.getAllStreamIds().get(0),defaultLockKey,2,latencyTracker);
      leftProcessStreamReceiver=rightProcessStreamReceiver;
    }
 else {
      throw new ExecutionPlanCreationException("String_Node_Str" + leftInputStreamId + "String_Node_Str"+ rightInputStreamId);
    }
  }
  SingleStreamRuntime leftStreamRuntime=SingleInputStreamParser.parseInputStream((SingleInputStream)joinInputStream.getLeftInputStream(),executionPlanContext,executors,streamDefinitionMap,!leftMetaStreamEvent.isTableEvent() ? null : tableDefinitionMap,eventTableMap,leftMetaStreamEvent,leftProcessStreamReceiver,true,latencyTracker,outputExpectsExpiredEvents);
  for (  VariableExpressionExecutor variableExpressionExecutor : executors) {
    variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX]=0;
  }
  int size=executors.size();
  SingleStreamRuntime rightStreamRuntime=SingleInputStreamParser.parseInputStream((SingleInputStream)joinInputStream.getRightInputStream(),executionPlanContext,executors,streamDefinitionMap,!rightMetaStreamEvent.isTableEvent() ? null : tableDefinitionMap,eventTableMap,rightMetaStreamEvent,rightProcessStreamReceiver,true,latencyTracker,outputExpectsExpiredEvents);
  for (int i=size; i < executors.size(); i++) {
    VariableExpressionExecutor variableExpressionExecutor=executors.get(i);
    variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX]=1;
  }
  if (leftMetaStreamEvent.isTableEvent()) {
    TableWindowProcessor tableWindowProcessor=new TableWindowProcessor(eventTableMap.get(leftInputStreamId));
    tableWindowProcessor.initProcessor(leftMetaStreamEvent.getLastInputDefinition(),new ExpressionExecutor[0],executionPlanContext,outputExpectsExpiredEvents);
    leftStreamRuntime.setProcessorChain(tableWindowProcessor);
  }
  if (rightMetaStreamEvent.isTableEvent()) {
    TableWindowProcessor tableWindowProcessor=new TableWindowProcessor(eventTableMap.get(rightInputStreamId));
    tableWindowProcessor.initProcessor(rightMetaStreamEvent.getLastInputDefinition(),new ExpressionExecutor[0],executionPlanContext,outputExpectsExpiredEvents);
    rightStreamRuntime.setProcessorChain(tableWindowProcessor);
  }
  MetaStateEvent metaStateEvent=new MetaStateEvent(2);
  metaStateEvent.addEvent(leftMetaStreamEvent);
  metaStateEvent.addEvent(rightMetaStreamEvent);
switch (joinInputStream.getType()) {
case FULL_OUTER_JOIN:
    leftOuterJoinProcessor=true;
case RIGHT_OUTER_JOIN:
  rightOuterJoinProcessor=true;
break;
case LEFT_OUTER_JOIN:
leftOuterJoinProcessor=true;
break;
}
Lock joinLock=new ReentrantLock();
JoinProcessor leftPreJoinProcessor=new JoinProcessor(true,true,leftOuterJoinProcessor);
JoinProcessor leftPostJoinProcessor=new JoinProcessor(true,false,leftOuterJoinProcessor);
FindableProcessor leftFindableProcessor=insertJoinProcessorsAndGetFindable(leftPreJoinProcessor,leftPostJoinProcessor,leftStreamRuntime,executionPlanContext,outputExpectsExpiredEvents);
JoinProcessor rightPreJoinProcessor=new JoinProcessor(false,true,rightOuterJoinProcessor);
JoinProcessor rightPostJoinProcessor=new JoinProcessor(false,false,rightOuterJoinProcessor);
FindableProcessor rightFindableProcessor=insertJoinProcessorsAndGetFindable(rightPreJoinProcessor,rightPostJoinProcessor,rightStreamRuntime,executionPlanContext,outputExpectsExpiredEvents);
leftPreJoinProcessor.setFindableProcessor(rightFindableProcessor);
leftPreJoinProcessor.setJoinLock(joinLock);
leftPostJoinProcessor.setFindableProcessor(rightFindableProcessor);
leftPostJoinProcessor.setJoinLock(joinLock);
rightPreJoinProcessor.setFindableProcessor(leftFindableProcessor);
rightPreJoinProcessor.setJoinLock(joinLock);
rightPostJoinProcessor.setFindableProcessor(leftFindableProcessor);
rightPostJoinProcessor.setJoinLock(joinLock);
Expression compareCondition=joinInputStream.getOnCompare();
if (compareCondition == null) {
compareCondition=Expression.value(true);
}
long withinTime=SiddhiConstants.ANY;
if (joinInputStream.getWithin() != null) {
withinTime=((TimeConstant)joinInputStream.getWithin()).getValue();
}
Finder leftFinder=rightFindableProcessor.constructFinder(compareCondition,metaStateEvent,executionPlanContext,executors,eventTableMap,0,withinTime);
Finder rightFinder=leftFindableProcessor.constructFinder(compareCondition,metaStateEvent,executionPlanContext,executors,eventTableMap,1,withinTime);
if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.LEFT) {
rightPreJoinProcessor.setTrigger(true);
rightPreJoinProcessor.setFinder(rightFinder);
rightPostJoinProcessor.setTrigger(true);
rightPostJoinProcessor.setFinder(rightFinder);
}
if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.RIGHT) {
leftPreJoinProcessor.setTrigger(true);
leftPreJoinProcessor.setFinder(leftFinder);
leftPostJoinProcessor.setTrigger(true);
leftPostJoinProcessor.setFinder(leftFinder);
}
JoinStreamRuntime joinStreamRuntime=new JoinStreamRuntime(executionPlanContext,metaStateEvent);
joinStreamRuntime.addRuntime(leftStreamRuntime);
joinStreamRuntime.addRuntime(rightStreamRuntime);
return joinStreamRuntime;
}

Fixed version (ground truth):
public static StreamRuntime parseInputStream(JoinInputStream joinInputStream,ExecutionPlanContext executionPlanContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,EventTable> eventTableMap,List<VariableExpressionExecutor> executors,LatencyTracker latencyTracker,boolean outputExpectsExpiredEvents){
  ProcessStreamReceiver leftProcessStreamReceiver;
  ProcessStreamReceiver rightProcessStreamReceiver;
  MetaStreamEvent leftMetaStreamEvent=new MetaStreamEvent();
  MetaStreamEvent rightMetaStreamEvent=new MetaStreamEvent();
  String leftInputStreamId=((SingleInputStream)joinInputStream.getLeftInputStream()).getStreamId();
  String rightInputStreamId=((SingleInputStream)joinInputStream.getRightInputStream()).getStreamId();
  boolean leftOuterJoinProcessor=false;
  boolean rightOuterJoinProcessor=false;
  if (joinInputStream.getAllStreamIds().size() == 2) {
    if (!streamDefinitionMap.containsKey(leftInputStreamId)) {
      leftMetaStreamEvent.setTableEvent(true);
    }
    if (!streamDefinitionMap.containsKey(rightInputStreamId)) {
      rightMetaStreamEvent.setTableEvent(true);
    }
    leftProcessStreamReceiver=new ProcessStreamReceiver(leftInputStreamId,latencyTracker);
    rightProcessStreamReceiver=new ProcessStreamReceiver(rightInputStreamId,latencyTracker);
    if (leftMetaStreamEvent.isTableEvent() && rightMetaStreamEvent.isTableEvent()) {
      throw new ExecutionPlanCreationException("String_Node_Str" + leftInputStreamId + "String_Node_Str"+ rightInputStreamId);
    }
  }
 else {
    if (streamDefinitionMap.containsKey(joinInputStream.getAllStreamIds().get(0))) {
      rightProcessStreamReceiver=new MultiProcessStreamReceiver(joinInputStream.getAllStreamIds().get(0),2,latencyTracker);
      leftProcessStreamReceiver=rightProcessStreamReceiver;
    }
 else {
      throw new ExecutionPlanCreationException("String_Node_Str" + leftInputStreamId + "String_Node_Str"+ rightInputStreamId);
    }
  }
  SingleStreamRuntime leftStreamRuntime=SingleInputStreamParser.parseInputStream((SingleInputStream)joinInputStream.getLeftInputStream(),executionPlanContext,executors,streamDefinitionMap,!leftMetaStreamEvent.isTableEvent() ? null : tableDefinitionMap,eventTableMap,leftMetaStreamEvent,leftProcessStreamReceiver,true,latencyTracker,outputExpectsExpiredEvents);
  for (  VariableExpressionExecutor variableExpressionExecutor : executors) {
    variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX]=0;
  }
  int size=executors.size();
  SingleStreamRuntime rightStreamRuntime=SingleInputStreamParser.parseInputStream((SingleInputStream)joinInputStream.getRightInputStream(),executionPlanContext,executors,streamDefinitionMap,!rightMetaStreamEvent.isTableEvent() ? null : tableDefinitionMap,eventTableMap,rightMetaStreamEvent,rightProcessStreamReceiver,true,latencyTracker,outputExpectsExpiredEvents);
  for (int i=size; i < executors.size(); i++) {
    VariableExpressionExecutor variableExpressionExecutor=executors.get(i);
    variableExpressionExecutor.getPosition()[SiddhiConstants.STREAM_EVENT_CHAIN_INDEX]=1;
  }
  if (leftMetaStreamEvent.isTableEvent()) {
    TableWindowProcessor tableWindowProcessor=new TableWindowProcessor(eventTableMap.get(leftInputStreamId));
    tableWindowProcessor.initProcessor(leftMetaStreamEvent.getLastInputDefinition(),new ExpressionExecutor[0],executionPlanContext,outputExpectsExpiredEvents);
    leftStreamRuntime.setProcessorChain(tableWindowProcessor);
  }
  if (rightMetaStreamEvent.isTableEvent()) {
    TableWindowProcessor tableWindowProcessor=new TableWindowProcessor(eventTableMap.get(rightInputStreamId));
    tableWindowProcessor.initProcessor(rightMetaStreamEvent.getLastInputDefinition(),new ExpressionExecutor[0],executionPlanContext,outputExpectsExpiredEvents);
    rightStreamRuntime.setProcessorChain(tableWindowProcessor);
  }
  MetaStateEvent metaStateEvent=new MetaStateEvent(2);
  metaStateEvent.addEvent(leftMetaStreamEvent);
  metaStateEvent.addEvent(rightMetaStreamEvent);
switch (joinInputStream.getType()) {
case FULL_OUTER_JOIN:
    leftOuterJoinProcessor=true;
case RIGHT_OUTER_JOIN:
  rightOuterJoinProcessor=true;
break;
case LEFT_OUTER_JOIN:
leftOuterJoinProcessor=true;
break;
}
Lock joinLock=new ReentrantLock();
JoinProcessor leftPreJoinProcessor=new JoinProcessor(true,true,leftOuterJoinProcessor);
JoinProcessor leftPostJoinProcessor=new JoinProcessor(true,false,leftOuterJoinProcessor);
FindableProcessor leftFindableProcessor=insertJoinProcessorsAndGetFindable(leftPreJoinProcessor,leftPostJoinProcessor,leftStreamRuntime,executionPlanContext,outputExpectsExpiredEvents);
JoinProcessor rightPreJoinProcessor=new JoinProcessor(false,true,rightOuterJoinProcessor);
JoinProcessor rightPostJoinProcessor=new JoinProcessor(false,false,rightOuterJoinProcessor);
FindableProcessor rightFindableProcessor=insertJoinProcessorsAndGetFindable(rightPreJoinProcessor,rightPostJoinProcessor,rightStreamRuntime,executionPlanContext,outputExpectsExpiredEvents);
leftPreJoinProcessor.setFindableProcessor(rightFindableProcessor);
leftPreJoinProcessor.setJoinLock(joinLock);
leftPostJoinProcessor.setFindableProcessor(rightFindableProcessor);
leftPostJoinProcessor.setJoinLock(joinLock);
rightPreJoinProcessor.setFindableProcessor(leftFindableProcessor);
rightPreJoinProcessor.setJoinLock(joinLock);
rightPostJoinProcessor.setFindableProcessor(leftFindableProcessor);
rightPostJoinProcessor.setJoinLock(joinLock);
Expression compareCondition=joinInputStream.getOnCompare();
if (compareCondition == null) {
compareCondition=Expression.value(true);
}
long withinTime=SiddhiConstants.ANY;
if (joinInputStream.getWithin() != null) {
withinTime=((TimeConstant)joinInputStream.getWithin()).getValue();
}
Finder leftFinder=rightFindableProcessor.constructFinder(compareCondition,metaStateEvent,executionPlanContext,executors,eventTableMap,0,withinTime);
Finder rightFinder=leftFindableProcessor.constructFinder(compareCondition,metaStateEvent,executionPlanContext,executors,eventTableMap,1,withinTime);
if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.LEFT) {
rightPreJoinProcessor.setTrigger(true);
rightPreJoinProcessor.setFinder(rightFinder);
rightPostJoinProcessor.setTrigger(true);
rightPostJoinProcessor.setFinder(rightFinder);
}
if (joinInputStream.getTrigger() != JoinInputStream.EventTrigger.RIGHT) {
leftPreJoinProcessor.setTrigger(true);
leftPreJoinProcessor.setFinder(leftFinder);
leftPostJoinProcessor.setTrigger(true);
leftPostJoinProcessor.setFinder(leftFinder);
}
JoinStreamRuntime joinStreamRuntime=new JoinStreamRuntime(executionPlanContext,metaStateEvent);
joinStreamRuntime.addRuntime(leftStreamRuntime);
joinStreamRuntime.addRuntime(rightStreamRuntime);
return joinStreamRuntime;
}