Program: 28753
Project: 28753
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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + source.getType()+ "String_Node_Str"+ 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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + table.getTableDefinition().getId()+ "String_Node_Str"+ 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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + sink.getType()+ "String_Node_Str"+ sink.getStreamDefinition().getId()+ "String_Node_Str"+ siddhiAppContext.getName()+ "String_Node_Str",t);
      }
    }
  }
  for (  Table table : tableMap.values()) {
    RecordTableHandlerManager recordTableHandlerManager=siddhiAppContext.getSiddhiContext().getRecordTableHandlerManager();
    if (recordTableHandlerManager != null) {
      String elementId=table.getHandler().getElementId();
      if (elementId != null) {
        recordTableHandlerManager.unregisterRecordTableHandler(elementId);
      }
    }
    table.shutdown();
  }
  for (  EternalReferencedHolder eternalReferencedHolder : siddhiAppContext.getEternalReferencedHolders()) {
    try {
      eternalReferencedHolder.stop();
    }
 catch (    Throwable t) {
      log.error(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + eternalReferencedHolder+ "String_Node_Str"+ 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;
}

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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + source.getType()+ "String_Node_Str"+ 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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + table.getTableDefinition().getId()+ "String_Node_Str"+ 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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + sink.getType()+ "String_Node_Str"+ sink.getStreamDefinition().getId()+ "String_Node_Str"+ 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(ExceptionUtil.getMessageWithContext(t,siddhiAppContext) + "String_Node_Str" + eternalReferencedHolder+ "String_Node_Str"+ 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;
}