Program: 28742
Project: 28742
Buggy source:
/** 
 * Parse an SiddhiApp returning SiddhiAppRuntime
 * @param siddhiApp       plan to be parsed
 * @param siddhiAppString
 * @param siddhiContext   SiddhiContext  @return SiddhiAppRuntime
 */
public static SiddhiAppRuntimeBuilder parse(SiddhiApp siddhiApp,String siddhiAppString,SiddhiContext siddhiContext){
  SiddhiAppContext siddhiAppContext=new SiddhiAppContext();
  siddhiAppContext.setSiddhiContext(siddhiContext);
  siddhiAppContext.setSiddhiAppString(siddhiAppString);
  try {
    Element element=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_NAME,null,siddhiApp.getAnnotations());
    if (element != null) {
      siddhiAppContext.setName(element.getValue());
    }
 else {
      siddhiAppContext.setName(UUID.randomUUID().toString());
    }
    Annotation annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ENFORCE_ORDER,siddhiApp.getAnnotations());
    if (annotation != null) {
      siddhiAppContext.setEnforceOrder(true);
    }
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ASYNC,siddhiApp.getAnnotations());
    if (annotation != null) {
      throw new SiddhiAppCreationException("String_Node_Str" + "String_Node_Str",annotation.getQueryContextStartIndex(),annotation.getQueryContextEndIndex());
    }
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_STATISTICS,siddhiApp.getAnnotations());
    List<Element> statisticsElements=new ArrayList<>();
    if (annotation != null) {
      statisticsElements=annotation.getElements();
    }
    if (siddhiContext.getStatisticsConfiguration() != null) {
      siddhiAppContext.setStatisticsManager(siddhiContext.getStatisticsConfiguration().getFactory().createStatisticsManager(siddhiContext.getStatisticsConfiguration().getMetricPrefix(),siddhiAppContext.getName(),statisticsElements));
    }
    Element statStateEnableElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,SiddhiConstants.ANNOTATION_ELEMENT_ENABLE,siddhiApp.getAnnotations());
    if (statStateEnableElement != null && Boolean.valueOf(statStateEnableElement.getValue())) {
      siddhiAppContext.setStatsEnabled(true);
    }
 else {
      Element statStateElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,null,siddhiApp.getAnnotations());
      if (annotation != null && (statStateElement == null || Boolean.valueOf(statStateElement.getValue()))) {
        siddhiAppContext.setStatsEnabled(true);
      }
    }
    Element statStateIncludElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,SiddhiConstants.ANNOTATION_ELEMENT_INCLUDE,siddhiApp.getAnnotations());
    siddhiAppContext.setIncludedMetrics(generateIncludedMetrics(statStateIncludElement));
    siddhiAppContext.setThreadBarrier(new ThreadBarrier());
    siddhiAppContext.setExecutorService(Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str").build()));
    siddhiAppContext.setScheduledExecutorService(Executors.newScheduledThreadPool(5,new ThreadFactoryBuilder().setNameFormat("String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str").build()));
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_PLAYBACK,siddhiApp.getAnnotations());
    if (annotation != null) {
      String idleTime=null;
      String increment=null;
      EventTimeBasedMillisTimestampGenerator timestampGenerator=new EventTimeBasedMillisTimestampGenerator(siddhiAppContext.getScheduledExecutorService());
      for (      Element e : annotation.getElements()) {
        if (SiddhiConstants.ANNOTATION_ELEMENT_IDLE_TIME.equalsIgnoreCase(e.getKey())) {
          idleTime=e.getValue();
        }
 else         if (SiddhiConstants.ANNOTATION_ELEMENT_INCREMENT.equalsIgnoreCase(e.getKey())) {
          increment=e.getValue();
        }
 else {
          throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str" + e.getKey());
        }
      }
      if (idleTime != null && increment == null) {
        throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str");
      }
 else       if (idleTime == null && increment != null) {
        throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str");
      }
 else       if (idleTime != null) {
        try {
          timestampGenerator.setIdleTime(SiddhiCompiler.parseTimeConstantDefinition(idleTime).value());
        }
 catch (        SiddhiParserException ex) {
          throw new SiddhiParserException("String_Node_Str" + idleTime + "String_Node_Str"+ "String_Node_Str",ex);
        }
        try {
          timestampGenerator.setIncrementInMilliseconds(SiddhiCompiler.parseTimeConstantDefinition(increment).value());
        }
 catch (        SiddhiParserException ex) {
          throw new SiddhiParserException("String_Node_Str" + increment + "String_Node_Str"+ "String_Node_Str",ex);
        }
      }
      siddhiAppContext.setTimestampGenerator(timestampGenerator);
      siddhiAppContext.setPlayback(true);
    }
 else {
      siddhiAppContext.setTimestampGenerator(new SystemCurrentTimeMillisTimestampGenerator());
    }
    siddhiAppContext.setSnapshotService(new SnapshotService(siddhiAppContext));
    siddhiAppContext.setPersistenceService(new PersistenceService(siddhiAppContext));
    siddhiAppContext.setElementIdGenerator(new ElementIdGenerator(siddhiAppContext.getName()));
  }
 catch (  DuplicateAnnotationException e) {
    throw new DuplicateAnnotationException(e.getMessageWithOutContext() + "String_Node_Str" + siddhiApp.toString(),e,e.getQueryContextStartIndex(),e.getQueryContextEndIndex(),siddhiAppContext.getName(),siddhiAppContext.getSiddhiAppString());
  }
  SiddhiAppRuntimeBuilder siddhiAppRuntimeBuilder=new SiddhiAppRuntimeBuilder(siddhiAppContext);
  defineStreamDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getStreamDefinitionMap(),siddhiAppContext);
  defineTableDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getTableDefinitionMap(),siddhiAppContext);
  defineWindowDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getWindowDefinitionMap(),siddhiAppContext);
  defineFunctionDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getFunctionDefinitionMap(),siddhiAppContext);
  defineAggregationDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getAggregationDefinitionMap(),siddhiAppContext);
  for (  Window window : siddhiAppRuntimeBuilder.getWindowMap().values()) {
    try {
      window.init(siddhiAppRuntimeBuilder.getTableMap(),siddhiAppRuntimeBuilder.getWindowMap(),window.getWindowDefinition().getId());
    }
 catch (    Throwable t) {
      ExceptionUtil.populateQueryContext(t,window.getWindowDefinition(),siddhiAppContext);
      throw t;
    }
  }
  int queryIndex=1;
  for (  ExecutionElement executionElement : siddhiApp.getExecutionElementList()) {
    if (executionElement instanceof Query) {
      try {
        QueryRuntime queryRuntime=QueryParser.parse((Query)executionElement,siddhiAppContext,siddhiAppRuntimeBuilder.getStreamDefinitionMap(),siddhiAppRuntimeBuilder.getTableDefinitionMap(),siddhiAppRuntimeBuilder.getWindowDefinitionMap(),siddhiAppRuntimeBuilder.getAggregationDefinitionMap(),siddhiAppRuntimeBuilder.getTableMap(),siddhiAppRuntimeBuilder.getAggregationMap(),siddhiAppRuntimeBuilder.getWindowMap(),siddhiAppRuntimeBuilder.getLockSynchronizer(),String.valueOf(queryIndex));
        siddhiAppRuntimeBuilder.addQuery(queryRuntime);
        queryIndex++;
      }
 catch (      Throwable t) {
        ExceptionUtil.populateQueryContext(t,(Query)executionElement,siddhiAppContext);
        throw t;
      }
    }
 else {
      try {
        PartitionRuntime partitionRuntime=PartitionParser.parse(siddhiAppRuntimeBuilder,(Partition)executionElement,siddhiAppContext,siddhiAppRuntimeBuilder.getStreamDefinitionMap(),queryIndex);
        siddhiAppRuntimeBuilder.addPartition(partitionRuntime);
        queryIndex+=((Partition)executionElement).getQueryList().size();
      }
 catch (      Throwable t) {
        ExceptionUtil.populateQueryContext(t,(Partition)executionElement,siddhiAppContext);
        throw t;
      }
    }
  }
  defineTriggerDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getTriggerDefinitionMap(),siddhiAppContext);
  return siddhiAppRuntimeBuilder;
}

Fixed version (ground truth):
/** 
 * Parse an SiddhiApp returning SiddhiAppRuntime
 * @param siddhiApp       plan to be parsed
 * @param siddhiAppString content of Siddhi application as string
 * @param siddhiContext   SiddhiContext  @return SiddhiAppRuntime
 * @return SiddhiAppRuntimeBuilder
 */
public static SiddhiAppRuntimeBuilder parse(SiddhiApp siddhiApp,String siddhiAppString,SiddhiContext siddhiContext){
  SiddhiAppContext siddhiAppContext=new SiddhiAppContext();
  siddhiAppContext.setSiddhiContext(siddhiContext);
  siddhiAppContext.setSiddhiAppString(siddhiAppString);
  try {
    Element element=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_NAME,null,siddhiApp.getAnnotations());
    if (element != null) {
      siddhiAppContext.setName(element.getValue());
    }
 else {
      siddhiAppContext.setName(UUID.randomUUID().toString());
    }
    Annotation annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ENFORCE_ORDER,siddhiApp.getAnnotations());
    if (annotation != null) {
      siddhiAppContext.setEnforceOrder(true);
    }
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_ASYNC,siddhiApp.getAnnotations());
    if (annotation != null) {
      throw new SiddhiAppCreationException("String_Node_Str" + "String_Node_Str",annotation.getQueryContextStartIndex(),annotation.getQueryContextEndIndex());
    }
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_STATISTICS,siddhiApp.getAnnotations());
    List<Element> statisticsElements=new ArrayList<>();
    if (annotation != null) {
      statisticsElements=annotation.getElements();
    }
    if (siddhiContext.getStatisticsConfiguration() != null) {
      siddhiAppContext.setStatisticsManager(siddhiContext.getStatisticsConfiguration().getFactory().createStatisticsManager(siddhiContext.getStatisticsConfiguration().getMetricPrefix(),siddhiAppContext.getName(),statisticsElements));
    }
    Element statStateEnableElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,SiddhiConstants.ANNOTATION_ELEMENT_ENABLE,siddhiApp.getAnnotations());
    if (statStateEnableElement != null && Boolean.valueOf(statStateEnableElement.getValue())) {
      siddhiAppContext.setStatsEnabled(true);
    }
 else {
      Element statStateElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,null,siddhiApp.getAnnotations());
      if (annotation != null && (statStateElement == null || Boolean.valueOf(statStateElement.getValue()))) {
        siddhiAppContext.setStatsEnabled(true);
      }
    }
    Element statStateIncludElement=AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_STATISTICS,SiddhiConstants.ANNOTATION_ELEMENT_INCLUDE,siddhiApp.getAnnotations());
    siddhiAppContext.setIncludedMetrics(generateIncludedMetrics(statStateIncludElement));
    siddhiAppContext.setThreadBarrier(new ThreadBarrier());
    siddhiAppContext.setExecutorService(Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str").build()));
    siddhiAppContext.setScheduledExecutorService(Executors.newScheduledThreadPool(5,new ThreadFactoryBuilder().setNameFormat("String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str").build()));
    annotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_PLAYBACK,siddhiApp.getAnnotations());
    if (annotation != null) {
      String idleTime=null;
      String increment=null;
      EventTimeBasedMillisTimestampGenerator timestampGenerator=new EventTimeBasedMillisTimestampGenerator(siddhiAppContext.getScheduledExecutorService());
      for (      Element e : annotation.getElements()) {
        if (SiddhiConstants.ANNOTATION_ELEMENT_IDLE_TIME.equalsIgnoreCase(e.getKey())) {
          idleTime=e.getValue();
        }
 else         if (SiddhiConstants.ANNOTATION_ELEMENT_INCREMENT.equalsIgnoreCase(e.getKey())) {
          increment=e.getValue();
        }
 else {
          throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str" + e.getKey());
        }
      }
      if (idleTime != null && increment == null) {
        throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str");
      }
 else       if (idleTime == null && increment != null) {
        throw new SiddhiAppValidationException("String_Node_Str" + "String_Node_Str");
      }
 else       if (idleTime != null) {
        try {
          timestampGenerator.setIdleTime(SiddhiCompiler.parseTimeConstantDefinition(idleTime).value());
        }
 catch (        SiddhiParserException ex) {
          throw new SiddhiParserException("String_Node_Str" + idleTime + "String_Node_Str"+ "String_Node_Str",ex);
        }
        try {
          timestampGenerator.setIncrementInMilliseconds(SiddhiCompiler.parseTimeConstantDefinition(increment).value());
        }
 catch (        SiddhiParserException ex) {
          throw new SiddhiParserException("String_Node_Str" + increment + "String_Node_Str"+ "String_Node_Str",ex);
        }
      }
      siddhiAppContext.setTimestampGenerator(timestampGenerator);
      siddhiAppContext.setPlayback(true);
    }
 else {
      siddhiAppContext.setTimestampGenerator(new SystemCurrentTimeMillisTimestampGenerator());
    }
    siddhiAppContext.setSnapshotService(new SnapshotService(siddhiAppContext));
    siddhiAppContext.setPersistenceService(new PersistenceService(siddhiAppContext));
    siddhiAppContext.setElementIdGenerator(new ElementIdGenerator(siddhiAppContext.getName()));
  }
 catch (  DuplicateAnnotationException e) {
    throw new DuplicateAnnotationException(e.getMessageWithOutContext() + "String_Node_Str" + siddhiApp.toString(),e,e.getQueryContextStartIndex(),e.getQueryContextEndIndex(),siddhiAppContext.getName(),siddhiAppContext.getSiddhiAppString());
  }
  SiddhiAppRuntimeBuilder siddhiAppRuntimeBuilder=new SiddhiAppRuntimeBuilder(siddhiAppContext);
  defineStreamDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getStreamDefinitionMap(),siddhiAppContext);
  defineTableDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getTableDefinitionMap(),siddhiAppContext);
  defineWindowDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getWindowDefinitionMap(),siddhiAppContext);
  defineFunctionDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getFunctionDefinitionMap(),siddhiAppContext);
  defineAggregationDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getAggregationDefinitionMap(),siddhiAppContext);
  for (  Window window : siddhiAppRuntimeBuilder.getWindowMap().values()) {
    try {
      window.init(siddhiAppRuntimeBuilder.getTableMap(),siddhiAppRuntimeBuilder.getWindowMap(),window.getWindowDefinition().getId());
    }
 catch (    Throwable t) {
      ExceptionUtil.populateQueryContext(t,window.getWindowDefinition(),siddhiAppContext);
      throw t;
    }
  }
  int queryIndex=1;
  for (  ExecutionElement executionElement : siddhiApp.getExecutionElementList()) {
    if (executionElement instanceof Query) {
      try {
        QueryRuntime queryRuntime=QueryParser.parse((Query)executionElement,siddhiAppContext,siddhiAppRuntimeBuilder.getStreamDefinitionMap(),siddhiAppRuntimeBuilder.getTableDefinitionMap(),siddhiAppRuntimeBuilder.getWindowDefinitionMap(),siddhiAppRuntimeBuilder.getAggregationDefinitionMap(),siddhiAppRuntimeBuilder.getTableMap(),siddhiAppRuntimeBuilder.getAggregationMap(),siddhiAppRuntimeBuilder.getWindowMap(),siddhiAppRuntimeBuilder.getLockSynchronizer(),String.valueOf(queryIndex));
        siddhiAppRuntimeBuilder.addQuery(queryRuntime);
        queryIndex++;
      }
 catch (      Throwable t) {
        ExceptionUtil.populateQueryContext(t,(Query)executionElement,siddhiAppContext);
        throw t;
      }
    }
 else {
      try {
        PartitionRuntime partitionRuntime=PartitionParser.parse(siddhiAppRuntimeBuilder,(Partition)executionElement,siddhiAppContext,siddhiAppRuntimeBuilder.getStreamDefinitionMap(),queryIndex);
        siddhiAppRuntimeBuilder.addPartition(partitionRuntime);
        queryIndex+=((Partition)executionElement).getQueryList().size();
      }
 catch (      Throwable t) {
        ExceptionUtil.populateQueryContext(t,(Partition)executionElement,siddhiAppContext);
        throw t;
      }
    }
  }
  defineTriggerDefinitions(siddhiAppRuntimeBuilder,siddhiApp.getTriggerDefinitionMap(),siddhiAppContext);
  return siddhiAppRuntimeBuilder;
}