Program: 28946
Project: 28946
Buggy source:
/** 
 * Parse a subscription and return corresponding QueryRuntime.
 * @param subscription         subscription to be parsed.
 * @param executionPlanContext associated Execution Plan context.
 * @param streamDefinitionMap  map containing user given stream definitions.
 * @param tableDefinitionMap   map containing table definitions.
 * @param eventTableMap        map containing event tables.
 * @return SubscriptionRuntime.
 */
public static SubscriptionRuntime parse(final Subscription subscription,ExecutionPlanContext executionPlanContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,AbstractDefinition> windowDefinitionMap,Map<String,EventTable> eventTableMap,Map<String,EventWindow> eventWindowMap,LockSynchronizer lockSynchronizer){
  SubscriptionRuntime subscriptionRuntime;
  Element nameElement=null;
  LatencyTracker latencyTracker=null;
  LockWrapper lockWrapper=null;
  try {
    nameElement=AnnotationHelper.getAnnotationElement("String_Node_Str","String_Node_Str",subscription.getAnnotations());
    if (executionPlanContext.isStatsEnabled() && executionPlanContext.getStatisticsManager() != null) {
      if (nameElement != null) {
        String metricName=executionPlanContext.getSiddhiContext().getStatisticsConfiguration().getMatricPrefix() + SiddhiConstants.METRIC_DELIMITER + SiddhiConstants.METRIC_INFIX_EXECUTION_PLANS+ SiddhiConstants.METRIC_DELIMITER+ executionPlanContext.getName()+ SiddhiConstants.METRIC_DELIMITER+ SiddhiConstants.METRIC_INFIX_SIDDHI+ SiddhiConstants.METRIC_DELIMITER+ SiddhiConstants.METRIC_INFIX_QUERIES+ SiddhiConstants.METRIC_DELIMITER+ nameElement.getValue();
        latencyTracker=executionPlanContext.getSiddhiContext().getStatisticsConfiguration().getFactory().createLatencyTracker(metricName,executionPlanContext.getStatisticsManager());
      }
    }
    Extension transportExtension=new Extension(){
      @Override public String getNamespace(){
        return SiddhiConstants.INPUT_TRANSPORT;
      }
      @Override public String getFunction(){
        return subscription.getTransport().getType();
      }
    }
;
    InputTransport inputTransport=(InputTransport)SiddhiClassLoader.loadExtensionImplementation(transportExtension,InputTransportExecutorExtensionHolder.getInstance(executionPlanContext));
    Extension mapperExtension=new Extension(){
      @Override public String getNamespace(){
        return SiddhiConstants.INPUT_MAPPER;
      }
      @Override public String getFunction(){
        return subscription.getMapping().getFormat();
      }
    }
;
    InputMapper inputMapper=(InputMapper)SiddhiClassLoader.loadExtensionImplementation(mapperExtension,InputMapperExecutorExtensionHolder.getInstance(executionPlanContext));
    StreamDefinition outputStreamDefinition=(StreamDefinition)streamDefinitionMap.get(subscription.getOutputStream().getId());
    if (outputStreamDefinition == null) {
      outputStreamDefinition=(StreamDefinition)windowDefinitionMap.get(subscription.getOutputStream().getId());
    }
    inputMapper.inferOutputStreamDefinition(outputStreamDefinition);
    OutputCallback outputCallback=OutputParser.constructOutputCallback(subscription.getOutputStream(),inputMapper.getOutputStreamDefinition(),eventTableMap,eventWindowMap,executionPlanContext,false);
    MetaStreamEvent metaStreamEvent=new MetaStreamEvent();
    metaStreamEvent.setOutputDefinition(inputMapper.getOutputStreamDefinition());
    for (    Attribute attribute : inputMapper.getOutputStreamDefinition().getAttributeList()) {
      metaStreamEvent.addOutputData(attribute);
    }
    inputMapper.init(outputCallback,metaStreamEvent);
    OutputRateLimiter outputRateLimiter=OutputParser.constructOutputRateLimiter(subscription.getOutputStream().getId(),subscription.getOutputRate(),false,false,executionPlanContext.getScheduledExecutorService(),executionPlanContext);
    subscriptionRuntime=new SubscriptionRuntime(inputTransport,inputMapper,outputRateLimiter,outputCallback);
    executionPlanContext.addEternalReferencedHolder(inputTransport);
    executionPlanContext.addEternalReferencedHolder(outputRateLimiter);
    if (outputRateLimiter instanceof WrappedSnapshotOutputRateLimiter) {
      throw new ExecutionPlanCreationException("String_Node_Str" + nameElement + "String_Node_Str"+ subscription.getTransport().getType());
    }
    outputRateLimiter.init(executionPlanContext,null);
    subscriptionRuntime.init(subscription.getTransport().getOptions(),executionPlanContext);
  }
 catch (  DuplicateDefinitionException e) {
    if (nameElement != null) {
      throw new DuplicateDefinitionException(e.getMessage() + "String_Node_Str" + nameElement.getValue(),e);
    }
 else {
      throw new DuplicateDefinitionException(e.getMessage(),e);
    }
  }
catch (  RuntimeException e) {
    if (nameElement != null) {
      throw new ExecutionPlanCreationException(e.getMessage() + "String_Node_Str" + nameElement.getValue(),e);
    }
 else {
      throw new ExecutionPlanCreationException(e.getMessage(),e);
    }
  }
  return subscriptionRuntime;
}

Fixed version (ground truth):
/** 
 * Parse a subscription and return corresponding QueryRuntime.
 * @param subscription         subscription to be parsed.
 * @param executionPlanContext associated Execution Plan context.
 * @param streamDefinitionMap  map containing user given stream definitions.
 * @param tableDefinitionMap   map containing table definitions.
 * @param eventTableMap        map containing event tables.
 * @return SubscriptionRuntime.
 */
public static SubscriptionRuntime parse(final Subscription subscription,ExecutionPlanContext executionPlanContext,Map<String,AbstractDefinition> streamDefinitionMap,Map<String,AbstractDefinition> tableDefinitionMap,Map<String,AbstractDefinition> windowDefinitionMap,Map<String,EventTable> eventTableMap,Map<String,EventWindow> eventWindowMap,LockSynchronizer lockSynchronizer){
  SubscriptionRuntime subscriptionRuntime;
  String subscriptionName=null;
  Element nameElement=null;
  LatencyTracker latencyTracker=null;
  LockWrapper lockWrapper=null;
  try {
    nameElement=AnnotationHelper.getAnnotationElement("String_Node_Str","String_Node_Str",subscription.getAnnotations());
    if (nameElement != null) {
      subscriptionName=nameElement.getValue();
    }
 else {
      subscriptionName="String_Node_Str" + UUID.randomUUID().toString();
    }
    if (executionPlanContext.isStatsEnabled() && executionPlanContext.getStatisticsManager() != null) {
      if (nameElement != null) {
        String metricName=executionPlanContext.getSiddhiContext().getStatisticsConfiguration().getMatricPrefix() + SiddhiConstants.METRIC_DELIMITER + SiddhiConstants.METRIC_INFIX_EXECUTION_PLANS+ SiddhiConstants.METRIC_DELIMITER+ executionPlanContext.getName()+ SiddhiConstants.METRIC_DELIMITER+ SiddhiConstants.METRIC_INFIX_SIDDHI+ SiddhiConstants.METRIC_DELIMITER+ SiddhiConstants.METRIC_INFIX_QUERIES+ SiddhiConstants.METRIC_DELIMITER+ subscriptionName;
        latencyTracker=executionPlanContext.getSiddhiContext().getStatisticsConfiguration().getFactory().createLatencyTracker(metricName,executionPlanContext.getStatisticsManager());
      }
    }
    Extension transportExtension=new Extension(){
      @Override public String getNamespace(){
        return SiddhiConstants.INPUT_TRANSPORT;
      }
      @Override public String getFunction(){
        return subscription.getTransport().getType();
      }
    }
;
    InputTransport inputTransport=(InputTransport)SiddhiClassLoader.loadExtensionImplementation(transportExtension,InputTransportExecutorExtensionHolder.getInstance(executionPlanContext));
    Extension mapperExtension=new Extension(){
      @Override public String getNamespace(){
        return SiddhiConstants.INPUT_MAPPER;
      }
      @Override public String getFunction(){
        return subscription.getMapping().getFormat();
      }
    }
;
    InputMapper inputMapper=(InputMapper)SiddhiClassLoader.loadExtensionImplementation(mapperExtension,InputMapperExecutorExtensionHolder.getInstance(executionPlanContext));
    StreamDefinition outputStreamDefinition=(StreamDefinition)streamDefinitionMap.get(subscription.getOutputStream().getId());
    if (outputStreamDefinition == null) {
      outputStreamDefinition=(StreamDefinition)windowDefinitionMap.get(subscription.getOutputStream().getId());
    }
    inputMapper.inferOutputStreamDefinition(outputStreamDefinition);
    OutputCallback outputCallback=OutputParser.constructOutputCallback(subscription.getOutputStream(),inputMapper.getOutputStreamDefinition(),eventTableMap,eventWindowMap,executionPlanContext,false,subscriptionName);
    MetaStreamEvent metaStreamEvent=new MetaStreamEvent();
    metaStreamEvent.setOutputDefinition(inputMapper.getOutputStreamDefinition());
    for (    Attribute attribute : inputMapper.getOutputStreamDefinition().getAttributeList()) {
      metaStreamEvent.addOutputData(attribute);
    }
    inputMapper.init(outputCallback,metaStreamEvent);
    OutputRateLimiter outputRateLimiter=OutputParser.constructOutputRateLimiter(subscription.getOutputStream().getId(),subscription.getOutputRate(),false,false,executionPlanContext.getScheduledExecutorService(),executionPlanContext,subscriptionName);
    subscriptionRuntime=new SubscriptionRuntime(inputTransport,inputMapper,outputRateLimiter,outputCallback);
    executionPlanContext.addEternalReferencedHolder(inputTransport);
    executionPlanContext.addEternalReferencedHolder(outputRateLimiter);
    if (outputRateLimiter instanceof WrappedSnapshotOutputRateLimiter) {
      throw new ExecutionPlanCreationException("String_Node_Str" + nameElement + "String_Node_Str"+ subscription.getTransport().getType());
    }
    outputRateLimiter.init(executionPlanContext,null,subscriptionName);
    subscriptionRuntime.init(subscription.getTransport().getOptions(),executionPlanContext);
  }
 catch (  DuplicateDefinitionException e) {
    if (nameElement != null) {
      throw new DuplicateDefinitionException(e.getMessage() + "String_Node_Str" + subscriptionName,e);
    }
 else {
      throw new DuplicateDefinitionException(e.getMessage(),e);
    }
  }
catch (  RuntimeException e) {
    if (nameElement != null) {
      throw new ExecutionPlanCreationException(e.getMessage() + "String_Node_Str" + subscriptionName,e);
    }
 else {
      throw new ExecutionPlanCreationException(e.getMessage(),e);
    }
  }
  return subscriptionRuntime;
}