Program: 28756
Project: 28756
Buggy source:
/** 
 * Method to construct AttributeProcessor list for the selector
 * @param selector                    Selector
 * @param id                          stream id
 * @param siddhiAppContext            siddhi app context
 * @param metaComplexEvent            meta ComplexEvent
 * @param tableMap                    Table Map
 * @param variableExpressionExecutors list of VariableExpressionExecutors
 * @param outputStream
 * @return list of AttributeProcessors
 */
private static List<AttributeProcessor> getAttributeProcessors(Selector selector,String id,SiddhiAppContext siddhiAppContext,MetaComplexEvent metaComplexEvent,Map<String,Table> tableMap,List<VariableExpressionExecutor> variableExpressionExecutors,OutputStream outputStream,String queryName){
  List<AttributeProcessor> attributeProcessorList=new ArrayList<AttributeProcessor>();
  StreamDefinition outputDefinition=StreamDefinition.id(id);
  outputDefinition.setQueryContextStartIndex(outputStream.getQueryContextStartIndex());
  outputDefinition.setQueryContextEndIndex(outputStream.getQueryContextEndIndex());
  List<OutputAttribute> outputAttributes=selector.getSelectionList();
  if (selector.getSelectionList().size() == 0) {
    if (metaComplexEvent instanceof MetaStreamEvent) {
      List<Attribute> attributeList=((MetaStreamEvent)metaComplexEvent).getLastInputDefinition().getAttributeList();
      for (      Attribute attribute : attributeList) {
        outputAttributes.add(new OutputAttribute(new Variable(attribute.getName())));
      }
    }
 else {
      for (      MetaStreamEvent metaStreamEvent : ((MetaStateEvent)metaComplexEvent).getMetaStreamEvents()) {
        List<Attribute> attributeList=metaStreamEvent.getLastInputDefinition().getAttributeList();
        for (        Attribute attribute : attributeList) {
          OutputAttribute outputAttribute=new OutputAttribute(new Variable(attribute.getName()));
          if (!outputAttributes.contains(outputAttribute)) {
            outputAttributes.add(outputAttribute);
          }
 else {
            List<AbstractDefinition> definitions=new ArrayList<AbstractDefinition>();
            for (            MetaStreamEvent aMetaStreamEvent : ((MetaStateEvent)metaComplexEvent).getMetaStreamEvents()) {
              definitions.add(aMetaStreamEvent.getLastInputDefinition());
            }
            throw new DuplicateAttributeException("String_Node_Str" + definitions,outputStream.getQueryContextStartIndex(),outputStream.getQueryContextEndIndex());
          }
        }
      }
    }
  }
  int i=0;
  for (  OutputAttribute outputAttribute : outputAttributes) {
    ExpressionExecutor expressionExecutor=ExpressionParser.parseExpression(outputAttribute.getExpression(),metaComplexEvent,SiddhiConstants.UNKNOWN_STATE,tableMap,variableExpressionExecutors,siddhiAppContext,!(selector.getGroupByList().isEmpty()),0,queryName);
    if (expressionExecutor instanceof VariableExpressionExecutor) {
      VariableExpressionExecutor executor=((VariableExpressionExecutor)expressionExecutor);
      if (metaComplexEvent instanceof MetaStateEvent) {
        ((MetaStateEvent)metaComplexEvent).addOutputData(new MetaStateEventAttribute(executor.getAttribute(),executor.getPosition()));
      }
 else {
        ((MetaStreamEvent)metaComplexEvent).addOutputData(executor.getAttribute());
      }
      outputDefinition.attribute(outputAttribute.getRename(),((VariableExpressionExecutor)expressionExecutor).getAttribute().getType());
    }
 else {
      if (metaComplexEvent instanceof MetaStateEvent) {
        ((MetaStateEvent)metaComplexEvent).addOutputData(null);
      }
 else {
        ((MetaStreamEvent)metaComplexEvent).addOutputData(null);
      }
      AttributeProcessor attributeProcessor=new AttributeProcessor(expressionExecutor);
      attributeProcessor.setOutputPosition(i);
      attributeProcessorList.add(attributeProcessor);
      outputDefinition.attribute(outputAttribute.getRename(),attributeProcessor.getOutputType());
    }
    i++;
  }
  metaComplexEvent.setOutputDefinition(outputDefinition);
  return attributeProcessorList;
}

Fixed version (ground truth):
/** 
 * Method to construct AttributeProcessor list for the selector.
 * @param selector                    Selector
 * @param id                          stream id
 * @param siddhiAppContext            siddhi app context
 * @param metaComplexEvent            meta ComplexEvent
 * @param tableMap                    Table Map
 * @param variableExpressionExecutors list of VariableExpressionExecutors
 * @param outputStream
 * @return list of AttributeProcessors
 */
private static List<AttributeProcessor> getAttributeProcessors(Selector selector,String id,SiddhiAppContext siddhiAppContext,MetaComplexEvent metaComplexEvent,Map<String,Table> tableMap,List<VariableExpressionExecutor> variableExpressionExecutors,OutputStream outputStream,String queryName,int metaPosition){
  List<AttributeProcessor> attributeProcessorList=new ArrayList<>();
  StreamDefinition outputDefinition=StreamDefinition.id(id);
  outputDefinition.setQueryContextStartIndex(outputStream.getQueryContextStartIndex());
  outputDefinition.setQueryContextEndIndex(outputStream.getQueryContextEndIndex());
  List<OutputAttribute> outputAttributes=selector.getSelectionList();
  if (selector.getSelectionList().size() == 0) {
    if (metaComplexEvent instanceof MetaStreamEvent) {
      List<Attribute> attributeList=((MetaStreamEvent)metaComplexEvent).getLastInputDefinition().getAttributeList();
      for (      Attribute attribute : attributeList) {
        outputAttributes.add(new OutputAttribute(new Variable(attribute.getName())));
      }
    }
 else {
      int position=0;
      for (      MetaStreamEvent metaStreamEvent : ((MetaStateEvent)metaComplexEvent).getMetaStreamEvents()) {
        if (metaPosition == SiddhiConstants.UNKNOWN_STATE || metaPosition == position) {
          List<Attribute> attributeList=metaStreamEvent.getLastInputDefinition().getAttributeList();
          for (          Attribute attribute : attributeList) {
            OutputAttribute outputAttribute=new OutputAttribute(new Variable(attribute.getName()));
            if (!outputAttributes.contains(outputAttribute)) {
              outputAttributes.add(outputAttribute);
            }
 else {
              List<AbstractDefinition> definitions=new ArrayList<>();
              for (              MetaStreamEvent aMetaStreamEvent : ((MetaStateEvent)metaComplexEvent).getMetaStreamEvents()) {
                definitions.add(aMetaStreamEvent.getLastInputDefinition());
              }
              throw new DuplicateAttributeException("String_Node_Str" + definitions,outputStream.getQueryContextStartIndex(),outputStream.getQueryContextEndIndex());
            }
          }
        }
        ++position;
      }
    }
  }
  int i=0;
  for (  OutputAttribute outputAttribute : outputAttributes) {
    ExpressionExecutor expressionExecutor=ExpressionParser.parseExpression(outputAttribute.getExpression(),metaComplexEvent,SiddhiConstants.UNKNOWN_STATE,tableMap,variableExpressionExecutors,siddhiAppContext,!(selector.getGroupByList().isEmpty()),0,queryName);
    if (expressionExecutor instanceof VariableExpressionExecutor) {
      VariableExpressionExecutor executor=((VariableExpressionExecutor)expressionExecutor);
      if (metaComplexEvent instanceof MetaStateEvent) {
        ((MetaStateEvent)metaComplexEvent).addOutputData(new MetaStateEventAttribute(executor.getAttribute(),executor.getPosition()));
      }
 else {
        ((MetaStreamEvent)metaComplexEvent).addOutputData(executor.getAttribute());
      }
      outputDefinition.attribute(outputAttribute.getRename(),((VariableExpressionExecutor)expressionExecutor).getAttribute().getType());
    }
 else {
      if (metaComplexEvent instanceof MetaStateEvent) {
        ((MetaStateEvent)metaComplexEvent).addOutputData(null);
      }
 else {
        ((MetaStreamEvent)metaComplexEvent).addOutputData(null);
      }
      AttributeProcessor attributeProcessor=new AttributeProcessor(expressionExecutor);
      attributeProcessor.setOutputPosition(i);
      attributeProcessorList.add(attributeProcessor);
      outputDefinition.attribute(outputAttribute.getRename(),attributeProcessor.getOutputType());
    }
    i++;
  }
  metaComplexEvent.setOutputDefinition(outputDefinition);
  return attributeProcessorList;
}