Program: 47642
Project: 47642
Buggy source:
public static void runSubscription(final String subscriptionName,final IPentahoSession session,final IParameterProvider sessionParameters,final SimpleUrlFactory urlFactory,final IOutputHandler outputHandler){
  try {
    ISubscriptionRepository subscriptionRepository=PentahoSystem.get(ISubscriptionRepository.class,session);
    ISubscription subscription=subscriptionRepository.getSubscription(subscriptionName,session);
    if (subscription == null) {
      return;
    }
    ISubscribeContent content=subscription.getContent();
    Map contentParameters=content.getParameters();
    Map subscriptionParameters=subscription.getParameters();
    ActionInfo contentInfo=ActionInfo.parseActionString(content.getActionReference());
    subscriptionParameters.put("String_Node_Str",contentInfo.getSolutionName());
    subscriptionParameters.put("String_Node_Str",contentInfo.getPath());
    subscriptionParameters.put("String_Node_Str",contentInfo.getActionName());
    SimpleParameterProvider parameterProvider=new SimpleParameterProvider(contentParameters);
    parameterProvider.setParameters(subscriptionParameters);
    ArrayList messages=new ArrayList();
    String instanceId=null;
    boolean persisted=false;
    String actionName=contentInfo.getActionName();
    int lastDot=actionName.lastIndexOf('.');
    String type=actionName.substring(lastDot + 1);
    IPluginManager pluginManager=PentahoSystem.get(IPluginManager.class,session);
    IContentGenerator generator=pluginManager.getContentGeneratorForType(type,session);
    if (generator == null) {
      IRuntimeContext runtime=null;
      try {
        ISolutionEngine solutionEngine=PentahoSystem.get(ISolutionEngine.class,session);
        solutionEngine.setLoggingLevel(PentahoSystem.loggingLevel);
        solutionEngine.init(session);
        Map parameterProviderMap=new HashMap();
        parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST,parameterProvider);
        parameterProviderMap.put(IParameterProvider.SCOPE_SESSION,sessionParameters);
        runtime=solutionEngine.execute(contentInfo.getSolutionName(),contentInfo.getPath(),actionName,"String_Node_Str",false,true,instanceId,persisted,parameterProviderMap,outputHandler,null,urlFactory,messages);
        if (!outputHandler.contentDone()) {
          IContentItem contentItem=outputHandler.getFeedbackContentItem();
          OutputStream outputStream=contentItem.getOutputStream(subscriptionName);
          if (runtime == null) {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatFailureMessage("String_Node_Str",runtime,buffer);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
 else           if (runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatSuccessMessage("String_Node_Str",runtime,buffer,false);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
 else {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatFailureMessage("String_Node_Str",runtime,buffer);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
        }
      }
 catch (      Throwable t) {
      }
 finally {
        if (runtime != null) {
          runtime.dispose();
        }
      }
    }
 else {
      generator.setOutputHandler(outputHandler);
      generator.setItemName(actionName);
      generator.setInstanceId(instanceId);
      generator.setSession(session);
      Map<String,IParameterProvider> parameterProviders=new HashMap<String,IParameterProvider>();
      parameterProviders.put(IParameterProvider.SCOPE_REQUEST,parameterProvider);
      parameterProviders.put(IParameterProvider.SCOPE_SESSION,new PentahoSessionParameterProvider(session));
      generator.setParameterProviders(parameterProviders);
      try {
        generator.createContent();
        if (!outputHandler.contentDone()) {
          String message=Messages.getInstance().getString("String_Node_Str",subscriptionName);
          writeMessage(message.toString(),outputHandler,subscriptionName,contentInfo.getSolutionName(),actionName,instanceId,session);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        if (!outputHandler.contentDone()) {
          String message=Messages.getInstance().getString("String_Node_Str",subscriptionName);
          writeMessage(message.toString(),outputHandler,subscriptionName,contentInfo.getSolutionName(),actionName,instanceId,session);
        }
      }
    }
  }
 catch (  Throwable t) {
    logger.error("String_Node_Str",t);
  }
}

Fixed version (ground truth):
public static void runSubscription(final String subscriptionName,final IPentahoSession session,final IParameterProvider sessionParameters,final SimpleUrlFactory urlFactory,final IOutputHandler outputHandler){
  try {
    ISubscriptionRepository subscriptionRepository=PentahoSystem.get(ISubscriptionRepository.class,session);
    ISubscription subscription=subscriptionRepository.getSubscription(subscriptionName,session);
    if (subscription == null) {
      return;
    }
    ISubscribeContent content=subscription.getContent();
    Map contentParameters=content.getParameters();
    Map subscriptionParameters=subscription.getParameters();
    ActionInfo contentInfo=ActionInfo.parseActionString(content.getActionReference());
    subscriptionParameters.put("String_Node_Str",contentInfo.getSolutionName());
    subscriptionParameters.put("String_Node_Str",contentInfo.getPath());
    subscriptionParameters.put("String_Node_Str",contentInfo.getActionName());
    SimpleParameterProvider parameterProvider=new SimpleParameterProvider(contentParameters);
    parameterProvider.setParameters(subscriptionParameters);
    ArrayList messages=new ArrayList();
    String instanceId=null;
    boolean persisted=false;
    String actionName=contentInfo.getActionName();
    int lastDot=actionName.lastIndexOf('.');
    String type=actionName.substring(lastDot + 1);
    IPluginManager pluginManager=PentahoSystem.get(IPluginManager.class,session);
    IContentGenerator generator=pluginManager.getContentGeneratorForType(type,session);
    if (generator == null) {
      IRuntimeContext runtime=null;
      try {
        ISolutionEngine solutionEngine=PentahoSystem.get(ISolutionEngine.class,session);
        solutionEngine.setLoggingLevel(PentahoSystem.loggingLevel);
        solutionEngine.init(session);
        Map parameterProviderMap=new HashMap();
        parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST,parameterProvider);
        parameterProviderMap.put(IParameterProvider.SCOPE_SESSION,sessionParameters);
        runtime=solutionEngine.execute(content.getActionReference(),"String_Node_Str",false,true,instanceId,persisted,parameterProviderMap,outputHandler,null,urlFactory,messages);
        if (!outputHandler.contentDone()) {
          IContentItem contentItem=outputHandler.getFeedbackContentItem();
          OutputStream outputStream=contentItem.getOutputStream(subscriptionName);
          if (runtime == null) {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatFailureMessage("String_Node_Str",runtime,buffer);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
 else           if (runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatSuccessMessage("String_Node_Str",runtime,buffer,false);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
 else {
            StringBuffer buffer=new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class,session).formatFailureMessage("String_Node_Str",runtime,buffer);
            outputStream.write(buffer.toString().getBytes());
            contentItem.closeOutputStream();
          }
        }
      }
 catch (      Throwable t) {
      }
 finally {
        if (runtime != null) {
          runtime.dispose();
        }
      }
    }
 else {
      generator.setOutputHandler(outputHandler);
      generator.setItemName(actionName);
      generator.setInstanceId(instanceId);
      generator.setSession(session);
      Map<String,IParameterProvider> parameterProviders=new HashMap<String,IParameterProvider>();
      parameterProviders.put(IParameterProvider.SCOPE_REQUEST,parameterProvider);
      parameterProviders.put(IParameterProvider.SCOPE_SESSION,new PentahoSessionParameterProvider(session));
      generator.setParameterProviders(parameterProviders);
      try {
        generator.createContent();
        if (!outputHandler.contentDone()) {
          String message=Messages.getInstance().getString("String_Node_Str",subscriptionName);
          writeMessage(message.toString(),outputHandler,subscriptionName,contentInfo.getSolutionName(),actionName,instanceId,session);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        if (!outputHandler.contentDone()) {
          String message=Messages.getInstance().getString("String_Node_Str",subscriptionName);
          writeMessage(message.toString(),outputHandler,subscriptionName,contentInfo.getSolutionName(),actionName,instanceId,session);
        }
      }
    }
  }
 catch (  Throwable t) {
    logger.error("String_Node_Str",t);
  }
}