Program: 28759
Project: 28759
Buggy source:
/** 
 * Parse a storeQuery and return corresponding StoreQueryRuntime.
 * @param storeQuery       storeQuery to be parsed.
 * @param siddhiAppContext associated Siddhi app context.
 * @param tableMap         keyvalue containing tables.
 * @param windowMap        keyvalue containing windows.
 * @param aggregationMap   keyvalue containing aggregation runtimes.
 * @return StoreQueryRuntime
 */
public static StoreQueryRuntime parse(StoreQuery storeQuery,SiddhiAppContext siddhiAppContext,Map<String,Table> tableMap,Map<String,Window> windowMap,Map<String,AggregationRuntime> aggregationMap){
  String queryName="String_Node_Str" + storeQuery.getInputStore().getStoreId();
  InputStore inputStore=storeQuery.getInputStore();
  Within within=null;
  Expression per=null;
  Expression onCondition=Expression.value(true);
  MetaStreamEvent metaStreamEvent=new MetaStreamEvent();
  metaStreamEvent.setInputReferenceId(inputStore.getStoreReferenceId());
  if (inputStore instanceof AggregationInputStore) {
    AggregationInputStore aggregationInputStore=(AggregationInputStore)inputStore;
    if (aggregationMap.get(inputStore.getStoreId()) == null) {
      throw new StoreQueryCreationException("String_Node_Str" + inputStore.getStoreId() + "String_Node_Str"+ "String_Node_Str");
    }
    if (aggregationInputStore.getPer() != null && aggregationInputStore.getWithin() != null) {
      within=aggregationInputStore.getWithin();
      per=aggregationInputStore.getPer();
    }
 else     if (aggregationInputStore.getPer() != null || aggregationInputStore.getWithin() != null) {
      throw new StoreQueryCreationException(inputStore.getStoreId() + "String_Node_Str");
    }
    if (((AggregationInputStore)inputStore).getOnCondition() != null) {
      onCondition=((AggregationInputStore)inputStore).getOnCondition();
    }
  }
 else   if (inputStore instanceof ConditionInputStore) {
    if (((ConditionInputStore)inputStore).getOnCondition() != null) {
      onCondition=((ConditionInputStore)inputStore).getOnCondition();
    }
  }
  List<VariableExpressionExecutor> variableExpressionExecutors=new ArrayList<>();
  Table table=tableMap.get(inputStore.getStoreId());
  if (table != null) {
    metaStreamEvent.setEventType(EventType.TABLE);
    initMetaStreamEvent(metaStreamEvent,table.getTableDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,table.getTableDefinition());
    CompiledCondition compiledCondition=table.compileCondition(onCondition,metaStreamInfoHolder,siddhiAppContext,variableExpressionExecutors,tableMap,queryName);
    StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(table,compiledCondition,queryName,metaStreamEvent.getEventType());
    populateStoreQueryRuntime(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName);
    return storeQueryRuntime;
  }
 else {
    AggregationRuntime aggregation=aggregationMap.get(inputStore.getStoreId());
    if (aggregation != null) {
      metaStreamEvent.setEventType(EventType.AGGREGATE);
      initMetaStreamEvent(metaStreamEvent,aggregation.getAggregationDefinition());
      MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,aggregation.getAggregationDefinition());
      CompiledCondition compiledCondition=aggregation.compileExpression(onCondition,within,per,metaStreamInfoHolder,variableExpressionExecutors,tableMap,queryName,siddhiAppContext);
      metaStreamInfoHolder=aggregation.getAlteredMatchingMetaInfoHolder();
      StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(aggregation,compiledCondition,queryName,metaStreamEvent.getEventType());
      populateStoreQueryRuntimeForAggregator(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName);
      ComplexEventPopulater complexEventPopulater=StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0),0,((IncrementalAggregateCompileCondition)compiledCondition).getAdditionalAttributes());
      ((IncrementalAggregateCompileCondition)compiledCondition).setComplexEventPopulater(complexEventPopulater);
      return storeQueryRuntime;
    }
 else {
      Window window=windowMap.get(inputStore.getStoreId());
      if (window != null) {
        metaStreamEvent.setEventType(EventType.WINDOW);
        initMetaStreamEvent(metaStreamEvent,window.getWindowDefinition());
        MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,window.getWindowDefinition());
        CompiledCondition compiledCondition=window.compileCondition(onCondition,generateMatchingMetaInfoHolder(metaStreamEvent,window.getWindowDefinition()),siddhiAppContext,variableExpressionExecutors,tableMap,queryName);
        StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(window,compiledCondition,queryName,metaStreamEvent.getEventType());
        populateStoreQueryRuntime(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName);
        return storeQueryRuntime;
      }
 else {
        throw new StoreQueryCreationException(inputStore.getStoreId() + "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Parse a storeQuery and return corresponding StoreQueryRuntime.
 * @param storeQuery       storeQuery to be parsed.
 * @param siddhiAppContext associated Siddhi app context.
 * @param tableMap         keyvalue containing tables.
 * @param windowMap        keyvalue containing windows.
 * @param aggregationMap   keyvalue containing aggregation runtimes.
 * @return StoreQueryRuntime
 */
public static StoreQueryRuntime parse(StoreQuery storeQuery,SiddhiAppContext siddhiAppContext,Map<String,Table> tableMap,Map<String,Window> windowMap,Map<String,AggregationRuntime> aggregationMap){
  String queryName="String_Node_Str" + storeQuery.getInputStore().getStoreId();
  InputStore inputStore=storeQuery.getInputStore();
  int metaPosition=SiddhiConstants.UNKNOWN_STATE;
  Within within=null;
  Expression per=null;
  Expression onCondition=Expression.value(true);
  MetaStreamEvent metaStreamEvent=new MetaStreamEvent();
  metaStreamEvent.setInputReferenceId(inputStore.getStoreReferenceId());
  if (inputStore instanceof AggregationInputStore) {
    AggregationInputStore aggregationInputStore=(AggregationInputStore)inputStore;
    if (aggregationMap.get(inputStore.getStoreId()) == null) {
      throw new StoreQueryCreationException("String_Node_Str" + inputStore.getStoreId() + "String_Node_Str"+ "String_Node_Str");
    }
    if (aggregationInputStore.getPer() != null && aggregationInputStore.getWithin() != null) {
      within=aggregationInputStore.getWithin();
      per=aggregationInputStore.getPer();
    }
 else     if (aggregationInputStore.getPer() != null || aggregationInputStore.getWithin() != null) {
      throw new StoreQueryCreationException(inputStore.getStoreId() + "String_Node_Str");
    }
    if (((AggregationInputStore)inputStore).getOnCondition() != null) {
      onCondition=((AggregationInputStore)inputStore).getOnCondition();
    }
  }
 else   if (inputStore instanceof ConditionInputStore) {
    if (((ConditionInputStore)inputStore).getOnCondition() != null) {
      onCondition=((ConditionInputStore)inputStore).getOnCondition();
    }
  }
  List<VariableExpressionExecutor> variableExpressionExecutors=new ArrayList<>();
  Table table=tableMap.get(inputStore.getStoreId());
  if (table != null) {
    metaStreamEvent.setEventType(EventType.TABLE);
    initMetaStreamEvent(metaStreamEvent,table.getTableDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,table.getTableDefinition());
    CompiledCondition compiledCondition=table.compileCondition(onCondition,metaStreamInfoHolder,siddhiAppContext,variableExpressionExecutors,tableMap,queryName);
    StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(table,compiledCondition,queryName,metaStreamEvent.getEventType());
    populateStoreQueryRuntime(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName,metaPosition);
    return storeQueryRuntime;
  }
 else {
    AggregationRuntime aggregation=aggregationMap.get(inputStore.getStoreId());
    if (aggregation != null) {
      metaStreamEvent.setEventType(EventType.AGGREGATE);
      initMetaStreamEvent(metaStreamEvent,aggregation.getAggregationDefinition());
      MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,aggregation.getAggregationDefinition());
      CompiledCondition compiledCondition=aggregation.compileExpression(onCondition,within,per,metaStreamInfoHolder,variableExpressionExecutors,tableMap,queryName,siddhiAppContext);
      metaStreamInfoHolder=aggregation.getAlteredMatchingMetaInfoHolder();
      StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(aggregation,compiledCondition,queryName,metaStreamEvent.getEventType());
      metaPosition=1;
      populateStoreQueryRuntime(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName,metaPosition);
      ComplexEventPopulater complexEventPopulater=StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0),0,((IncrementalAggregateCompileCondition)compiledCondition).getAdditionalAttributes());
      ((IncrementalAggregateCompileCondition)compiledCondition).setComplexEventPopulater(complexEventPopulater);
      return storeQueryRuntime;
    }
 else {
      Window window=windowMap.get(inputStore.getStoreId());
      if (window != null) {
        metaStreamEvent.setEventType(EventType.WINDOW);
        initMetaStreamEvent(metaStreamEvent,window.getWindowDefinition());
        MatchingMetaInfoHolder metaStreamInfoHolder=generateMatchingMetaInfoHolder(metaStreamEvent,window.getWindowDefinition());
        CompiledCondition compiledCondition=window.compileCondition(onCondition,generateMatchingMetaInfoHolder(metaStreamEvent,window.getWindowDefinition()),siddhiAppContext,variableExpressionExecutors,tableMap,queryName);
        StoreQueryRuntime storeQueryRuntime=new StoreQueryRuntime(window,compiledCondition,queryName,metaStreamEvent.getEventType());
        populateStoreQueryRuntime(storeQueryRuntime,metaStreamInfoHolder,storeQuery.getSelector(),variableExpressionExecutors,siddhiAppContext,tableMap,queryName,metaPosition);
        return storeQueryRuntime;
      }
 else {
        throw new StoreQueryCreationException(inputStore.getStoreId() + "String_Node_Str");
      }
    }
  }
}