Program: 28701
Project: 28701
Buggy source:
public synchronized void shutdown(){
  SourceHandlerManager sourceHandlerManager=siddhiAppContext.getSiddhiContext().getSourceHandlerManager();
  for (  List<Source> sources : sourceMap.values()) {
    for (    Source source : sources) {
      try {
        if (sourceHandlerManager != null) {
          sourceHandlerManager.unregisterSourceHandler(source.getMapper().getHandler().getElementId());
        }
        source.shutdown();
      }
 catch (      Throwable t) {
        log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(source.getType())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(source.getStreamDefinition().getId())+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",t);
      }
    }
  }
  for (  Table table : tableMap.values()) {
    try {
      table.shutdown();
    }
 catch (    Throwable t) {
      log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(table.getTableDefinition().getId())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
    }
  }
  SinkHandlerManager sinkHandlerManager=siddhiAppContext.getSiddhiContext().getSinkHandlerManager();
  for (  List<Sink> sinks : sinkMap.values()) {
    for (    Sink sink : sinks) {
      try {
        if (sinkHandlerManager != null) {
          sinkHandlerManager.unregisterSinkHandler(sink.getHandler().getElementId());
        }
        sink.shutdown();
      }
 catch (      Throwable t) {
        log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(sink.getType())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(sink.getStreamDefinition().getId())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
      }
    }
  }
  for (  Table table : tableMap.values()) {
    RecordTableHandlerManager recordTableHandlerManager=siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
    if (recordTableHandlerManager != null) {
      String elementId=null;
      RecordTableHandler recordTableHandler=table.getHandler();
      if (recordTableHandler != null) {
        elementId=recordTableHandler.getElementId();
      }
      if (elementId != null) {
        recordTableHandlerManager.unregisterRecordTableHandler(elementId);
      }
    }
    table.shutdown();
  }
  for (  EternalReferencedHolder eternalReferencedHolder : siddhiAppContext.getEternalReferencedHolders()) {
    try {
      eternalReferencedHolder.stop();
    }
 catch (    Throwable t) {
      log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(eternalReferencedHolder.toString())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
    }
  }
  inputManager.disconnect();
  for (  Scheduler scheduler : siddhiAppContext.getSchedulers()) {
    scheduler.stop();
  }
  Thread thread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e) {
      }
      for (      StreamJunction streamJunction : streamJunctionMap.values()) {
        streamJunction.stopProcessing();
      }
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e) {
      }
      siddhiAppContext.getScheduledExecutorService().shutdownNow();
      siddhiAppContext.getExecutorService().shutdownNow();
    }
  }
,"String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str");
  thread.start();
  if (siddhiAppRuntimeMap != null) {
    siddhiAppRuntimeMap.remove(siddhiAppContext.getName());
  }
  if (siddhiAppContext.getStatisticsManager() != null) {
    if (siddhiAppContext.isStatsEnabled()) {
      siddhiAppContext.getStatisticsManager().stopReporting();
    }
    siddhiAppContext.getStatisticsManager().cleanup();
  }
  running=false;
}

Fixed version (ground truth):
public synchronized void shutdown(){
  SourceHandlerManager sourceHandlerManager=siddhiAppContext.getSiddhiContext().getSourceHandlerManager();
  for (  List<Source> sources : sourceMap.values()) {
    for (    Source source : sources) {
      try {
        if (sourceHandlerManager != null) {
          sourceHandlerManager.unregisterSourceHandler(source.getMapper().getHandler().getElementId());
        }
        source.shutdown();
      }
 catch (      Throwable t) {
        log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(source.getType())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(source.getStreamDefinition().getId())+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",t);
      }
    }
  }
  for (  Table table : tableMap.values()) {
    try {
      table.shutdown();
    }
 catch (    Throwable t) {
      log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(table.getTableDefinition().getId())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
    }
  }
  SinkHandlerManager sinkHandlerManager=siddhiAppContext.getSiddhiContext().getSinkHandlerManager();
  for (  List<Sink> sinks : sinkMap.values()) {
    for (    Sink sink : sinks) {
      try {
        if (sinkHandlerManager != null) {
          sinkHandlerManager.unregisterSinkHandler(sink.getHandler().getElementId());
        }
        sink.shutdown();
      }
 catch (      Throwable t) {
        log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(sink.getType())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(sink.getStreamDefinition().getId())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
      }
    }
  }
  for (  Table table : tableMap.values()) {
    RecordTableHandlerManager recordTableHandlerManager=siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
    if (recordTableHandlerManager != null) {
      String elementId=null;
      RecordTableHandler recordTableHandler=table.getHandler();
      if (recordTableHandler != null) {
        elementId=recordTableHandler.getElementId();
      }
      if (elementId != null) {
        recordTableHandlerManager.unregisterRecordTableHandler(elementId);
      }
    }
    table.shutdown();
  }
  for (  Scheduler scheduler : siddhiAppContext.getSchedulers()) {
    scheduler.stop();
  }
  for (  EternalReferencedHolder eternalReferencedHolder : siddhiAppContext.getEternalReferencedHolders()) {
    try {
      eternalReferencedHolder.stop();
    }
 catch (    Throwable t) {
      log.error(StringUtil.removeCRLFCharacters(ExceptionUtil.getMessageWithContext(t,siddhiAppContext)) + "String_Node_Str" + StringUtil.removeCRLFCharacters(eternalReferencedHolder.toString())+ "String_Node_Str"+ StringUtil.removeCRLFCharacters(siddhiAppContext.getName())+ "String_Node_Str",t);
    }
  }
  inputManager.disconnect();
  Thread thread=new Thread(new Runnable(){
    @Override public void run(){
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e) {
      }
      for (      StreamJunction streamJunction : streamJunctionMap.values()) {
        streamJunction.stopProcessing();
      }
      try {
        Thread.sleep(1000);
      }
 catch (      InterruptedException e) {
      }
      siddhiAppContext.getScheduledExecutorService().shutdownNow();
      siddhiAppContext.getExecutorService().shutdownNow();
    }
  }
,"String_Node_Str" + siddhiAppContext.getName() + "String_Node_Str");
  thread.start();
  if (siddhiAppRuntimeMap != null) {
    siddhiAppRuntimeMap.remove(siddhiAppContext.getName());
  }
  if (siddhiAppContext.getStatisticsManager() != null) {
    if (siddhiAppContext.isStatsEnabled()) {
      siddhiAppContext.getStatisticsManager().stopReporting();
    }
    siddhiAppContext.getStatisticsManager().cleanup();
  }
  running=false;
}