Program: 28929
Project: 28929
Buggy source:
public static void addEventSink(StreamDefinition streamDefinition,ConcurrentMap<String,List<Sink>> eventSinkMap,ExecutionPlanContext executionPlanContext){
  for (  Annotation sinkAnnotation : streamDefinition.getAnnotations()) {
    if (SiddhiConstants.ANNOTATION_SINK.equalsIgnoreCase(sinkAnnotation.getName())) {
      Annotation mapAnnotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_MAP,sinkAnnotation.getAnnotations());
      if (mapAnnotation == null) {
        mapAnnotation=Annotation.annotation(SiddhiConstants.ANNOTATION_MAP).element(SiddhiConstants.ANNOTATION_ELEMENT_TYPE,"String_Node_Str");
      }
      Annotation distributionAnnotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_DISTRIBUTION,sinkAnnotation.getAnnotations());
      if (mapAnnotation != null) {
        String[] supportedDynamicOptions=null;
        List<OptionHolder> destinationOptHolders=new ArrayList<>();
        String sinkType=sinkAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
        Extension sinkExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_SINK,sinkType,sinkAnnotation,SiddhiConstants.NAMESPACE_SINK);
        ConfigReader sinkConfigReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(sinkExtension.getNamespace(),sinkExtension.getName());
        final boolean isDistributedTransport=(distributionAnnotation != null);
        boolean isMultiClient=false;
        if (isDistributedTransport) {
          Sink sink=createSink(sinkExtension,executionPlanContext);
          isMultiClient=isMultiClientDistributedTransport(sink,streamDefinition,distributionAnnotation);
          supportedDynamicOptions=sink.getSupportedDynamicOptions();
          destinationOptHolders=createDestinationOptionHolders(distributionAnnotation,streamDefinition,sink);
        }
        final String mapType=mapAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
        if (sinkType != null && mapType != null) {
          Sink sink;
          if (isDistributedTransport) {
            sink=(isMultiClient) ? new MultiClientDistributedTransport() : new SingleClientDistributedTransport();
          }
 else {
            sink=createSink(sinkExtension,executionPlanContext);
          }
          if (supportedDynamicOptions == null) {
            supportedDynamicOptions=sink.getSupportedDynamicOptions();
          }
          Extension mapperExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_MAP,mapType,sinkAnnotation,SiddhiConstants.NAMESPACE_SINK_MAPPER);
          ConfigReader mapperConfigReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(sinkExtension.getNamespace(),sinkExtension.getName());
          SinkMapper sinkMapper=(SinkMapper)SiddhiClassLoader.loadExtensionImplementation(mapperExtension,SinkMapperExecutorExtensionHolder.getInstance(executionPlanContext));
          org.wso2.siddhi.annotation.Extension sinkExt=sink.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class);
          OptionHolder transportOptionHolder=constructOptionProcessor(streamDefinition,sinkAnnotation,sinkExt,supportedDynamicOptions);
          OptionHolder mapOptionHolder=constructOptionProcessor(streamDefinition,mapAnnotation,sinkMapper.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class),sinkMapper.getSupportedDynamicOptions());
          String payload=getPayload(mapAnnotation);
          OptionHolder distributionOptHolder=null;
          if (isDistributedTransport) {
            distributionOptHolder=constructOptionProcessor(streamDefinition,distributionAnnotation,sinkExt,supportedDynamicOptions);
            String strategyType=distributionOptHolder.validateAndGetStaticValue(SiddhiConstants.DISTRIBUTION_STRATEGY_KEY);
            Extension strategyExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_SINK,strategyType,sinkAnnotation,SiddhiConstants.NAMESPACE_DISTRIBUTION_STRATEGY);
            ConfigReader configReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(strategyExtension.getNamespace(),strategyExtension.getName());
            DistributionStrategy distributionStrategy=(DistributionStrategy)SiddhiClassLoader.loadExtensionImplementation(strategyExtension,DistributionStrategyExtensionHolder.getInstance(executionPlanContext));
            distributionStrategy.init(streamDefinition,transportOptionHolder,distributionOptHolder,destinationOptHolders,configReader);
            ((DistributedTransport)sink).init(streamDefinition,sinkType,transportOptionHolder,sinkConfigReader,sinkMapper,mapType,mapOptionHolder,payload,mapperConfigReader,executionPlanContext,destinationOptHolders,sinkAnnotation,distributionStrategy,supportedDynamicOptions);
          }
 else {
            sink.init(streamDefinition,sinkType,transportOptionHolder,sinkConfigReader,sinkMapper,mapType,mapOptionHolder,payload,mapperConfigReader,executionPlanContext);
          }
          OutputGroupDeterminer groupDeterminer=constructOutputGroupDeterminer(transportOptionHolder,distributionOptHolder,streamDefinition,destinationOptHolders.size());
          if (groupDeterminer != null) {
            sink.getMapper().setGroupDeterminer(groupDeterminer);
          }
          List<Sink> eventSinks=eventSinkMap.get(streamDefinition.getId());
          if (eventSinks == null) {
            eventSinks=new ArrayList<>();
            eventSinks.add(sink);
            eventSinkMap.put(streamDefinition.getId(),eventSinks);
          }
 else {
            eventSinks.add(sink);
          }
        }
      }
 else {
        throw new ExecutionPlanCreationException("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
public static void addEventSink(StreamDefinition streamDefinition,ConcurrentMap<String,List<Sink>> eventSinkMap,ExecutionPlanContext executionPlanContext){
  for (  Annotation sinkAnnotation : streamDefinition.getAnnotations()) {
    if (SiddhiConstants.ANNOTATION_SINK.equalsIgnoreCase(sinkAnnotation.getName())) {
      Annotation mapAnnotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_MAP,sinkAnnotation.getAnnotations());
      if (mapAnnotation == null) {
        mapAnnotation=Annotation.annotation(SiddhiConstants.ANNOTATION_MAP).element(SiddhiConstants.ANNOTATION_ELEMENT_TYPE,"String_Node_Str");
      }
      Annotation distributionAnnotation=AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_DISTRIBUTION,sinkAnnotation.getAnnotations());
      if (mapAnnotation != null) {
        String[] supportedDynamicOptions=null;
        List<OptionHolder> destinationOptHolders=new ArrayList<>();
        String sinkType=sinkAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
        Extension sinkExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_SINK,sinkType,sinkAnnotation,SiddhiConstants.NAMESPACE_SINK);
        ConfigReader sinkConfigReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(sinkExtension.getNamespace(),sinkExtension.getName());
        final boolean isDistributedTransport=(distributionAnnotation != null);
        boolean isMultiClient=false;
        if (isDistributedTransport) {
          Sink sink=createSink(sinkExtension,executionPlanContext);
          isMultiClient=isMultiClientDistributedTransport(sink,streamDefinition,distributionAnnotation);
          supportedDynamicOptions=sink.getSupportedDynamicOptions();
          destinationOptHolders=createDestinationOptionHolders(distributionAnnotation,streamDefinition,sink);
        }
        final String mapType=mapAnnotation.getElement(SiddhiConstants.ANNOTATION_ELEMENT_TYPE);
        if (sinkType != null && mapType != null) {
          Sink sink;
          if (isDistributedTransport) {
            sink=(isMultiClient) ? new MultiClientDistributedSink() : new SingleClientDistributedSink();
          }
 else {
            sink=createSink(sinkExtension,executionPlanContext);
          }
          if (supportedDynamicOptions == null) {
            supportedDynamicOptions=sink.getSupportedDynamicOptions();
          }
          Extension mapperExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_MAP,mapType,sinkAnnotation,SiddhiConstants.NAMESPACE_SINK_MAPPER);
          ConfigReader mapperConfigReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(sinkExtension.getNamespace(),sinkExtension.getName());
          SinkMapper sinkMapper=(SinkMapper)SiddhiClassLoader.loadExtensionImplementation(mapperExtension,SinkMapperExecutorExtensionHolder.getInstance(executionPlanContext));
          org.wso2.siddhi.annotation.Extension sinkExt=sink.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class);
          OptionHolder transportOptionHolder=constructOptionProcessor(streamDefinition,sinkAnnotation,sinkExt,supportedDynamicOptions);
          OptionHolder mapOptionHolder=constructOptionProcessor(streamDefinition,mapAnnotation,sinkMapper.getClass().getAnnotation(org.wso2.siddhi.annotation.Extension.class),sinkMapper.getSupportedDynamicOptions());
          String payload=getPayload(mapAnnotation);
          OptionHolder distributionOptHolder=null;
          if (isDistributedTransport) {
            distributionOptHolder=constructOptionProcessor(streamDefinition,distributionAnnotation,sinkExt,supportedDynamicOptions);
            String strategyType=distributionOptHolder.validateAndGetStaticValue(SiddhiConstants.DISTRIBUTION_STRATEGY_KEY);
            Extension strategyExtension=constructExtension(streamDefinition,SiddhiConstants.ANNOTATION_SINK,strategyType,sinkAnnotation,SiddhiConstants.NAMESPACE_DISTRIBUTION_STRATEGY);
            ConfigReader configReader=executionPlanContext.getSiddhiContext().getConfigManager().generateConfigReader(strategyExtension.getNamespace(),strategyExtension.getName());
            DistributionStrategy distributionStrategy=(DistributionStrategy)SiddhiClassLoader.loadExtensionImplementation(strategyExtension,DistributionStrategyExtensionHolder.getInstance(executionPlanContext));
            distributionStrategy.init(streamDefinition,transportOptionHolder,distributionOptHolder,destinationOptHolders,configReader);
            ((DistributedTransport)sink).init(streamDefinition,sinkType,transportOptionHolder,sinkConfigReader,sinkMapper,mapType,mapOptionHolder,payload,mapperConfigReader,executionPlanContext,destinationOptHolders,sinkAnnotation,distributionStrategy,supportedDynamicOptions);
          }
 else {
            sink.init(streamDefinition,sinkType,transportOptionHolder,sinkConfigReader,sinkMapper,mapType,mapOptionHolder,payload,mapperConfigReader,executionPlanContext);
          }
          OutputGroupDeterminer groupDeterminer=constructOutputGroupDeterminer(transportOptionHolder,distributionOptHolder,streamDefinition,destinationOptHolders.size());
          if (groupDeterminer != null) {
            sink.getMapper().setGroupDeterminer(groupDeterminer);
          }
          List<Sink> eventSinks=eventSinkMap.get(streamDefinition.getId());
          if (eventSinks == null) {
            eventSinks=new ArrayList<>();
            eventSinks.add(sink);
            eventSinkMap.put(streamDefinition.getId(),eventSinks);
          }
 else {
            eventSinks.add(sink);
          }
        }
      }
 else {
        throw new ExecutionPlanCreationException("String_Node_Str");
      }
    }
  }
}