Program: 21329
Project: 21329
Buggy source:
public PluginStep doStep(PluginStep step,DownloadLink downloadLink){
  if (step == null)   return null;
  try {
    if (!getFileInformation(downloadLink)) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_FILE_NOT_FOUND);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    String steplink=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
    if (steplink == null) {
      downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      if (downloadurl == null) {
        downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      }
      if (downloadurl == null) {
        downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      }
      if (downloadurl == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
    }
 else {
      downloadurl="String_Node_Str" + steplink + "String_Node_Str";
      downloadcookie=requestInfo.getCookie();
      requestInfo=HTTP.getRequest(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
      downloadcookie=downloadcookie + requestInfo.getCookie();
      referrerurl=downloadurl;
      if (requestInfo.getLocation() != null) {
        downloadurl=requestInfo.getLocation();
        requestInfo=HTTP.getRequest(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
        downloadcookie=requestInfo.getCookie();
        referrerurl=downloadurl;
      }
      if (requestInfo.containsHTML("String_Node_Str")) {
        captchaFile=getLocalCaptchaFile(this);
        HTTPConnection captcha_con=new HTTPConnection(new URL("String_Node_Str").openConnection());
        captcha_con.setRequestProperty("String_Node_Str",referrerurl);
        captcha_con.setRequestProperty("String_Node_Str",downloadcookie);
        if (!captcha_con.getContentType().contains("String_Node_Str") && !JDUtilities.download(captchaFile,captcha_con) || !captchaFile.exists()) {
          logger.severe("String_Node_Str");
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_IMAGEERROR);
          return step;
        }
        if ((captchaCode=Plugin.getCaptchaCode(captchaFile,this)) == null) {
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
          return step;
        }
        downloadurl="String_Node_Str" + steplink + "String_Node_Str"+ captchaCode;
        requestInfo=HTTP.getRequest((new URL(downloadurl)),downloadcookie,referrerurl,false);
        if (requestInfo.getLocation() != null && requestInfo.getLocation().contains("String_Node_Str")) {
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
          return step;
        }
        downloadcookie=downloadcookie + requestInfo.getCookie();
      }
      steplink=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      if (steplink == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
      downloadurl="String_Node_Str" + steplink;
      requestInfo=HTTP.getRequest(new URL(downloadurl),downloadcookie,referrerurl,false);
      if (requestInfo.getLocation() == null || requestInfo.getLocation().contains("String_Node_Str")) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
      downloadurl=requestInfo.getLocation();
      if (downloadurl == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
    }
    requestInfo=HTTP.getRequestWithoutHtmlCode(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
    HTTPConnection urlConnection=requestInfo.getConnection();
    String filename=getFileNameFormHeader(urlConnection);
    if (urlConnection.getContentLength() == 0) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_TEMPORARILY_UNAVAILABLE);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    downloadLink.setDownloadMax(urlConnection.getContentLength());
    downloadLink.setName(filename);
    long length=downloadLink.getDownloadMax();
    dl=new RAFDownload(this,downloadLink,urlConnection);
    dl.setChunkNum(1);
    dl.setResume(false);
    dl.setFilesize(length);
    if (!dl.startDownload() && step.getStatus() != PluginStep.STATUS_ERROR && step.getStatus() != PluginStep.STATUS_TODO) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_TEMPORARILY_UNAVAILABLE);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    return step;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  step.setStatus(PluginStep.STATUS_ERROR);
  downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
  return step;
}

Fixed version (ground truth):
public PluginStep doStep(PluginStep step,DownloadLink downloadLink){
  if (step == null)   return null;
  try {
    if (!getFileInformation(downloadLink)) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_FILE_NOT_FOUND);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    String steplink=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
    if (steplink == null) {
      downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      if (downloadurl == null) {
        downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      }
      if (downloadurl == null) {
        downloadurl=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      }
      if (downloadurl == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
    }
 else {
      downloadurl="String_Node_Str" + steplink + "String_Node_Str";
      downloadcookie=requestInfo.getCookie();
      requestInfo=HTTP.getRequest(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
      downloadcookie=downloadcookie + requestInfo.getCookie();
      referrerurl=downloadurl;
      if (requestInfo.getLocation() != null) {
        downloadurl=requestInfo.getLocation();
        requestInfo=HTTP.getRequest(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
        downloadcookie=requestInfo.getCookie();
        referrerurl=downloadurl;
      }
      if (requestInfo.containsHTML("String_Node_Str")) {
        captchaFile=getLocalCaptchaFile(this);
        HTTPConnection captcha_con=new HTTPConnection(new URL("String_Node_Str").openConnection());
        captcha_con.setRequestProperty("String_Node_Str",referrerurl);
        captcha_con.setRequestProperty("String_Node_Str",downloadcookie);
        if (!captcha_con.getContentType().contains("String_Node_Str") && !JDUtilities.download(captchaFile,captcha_con) || !captchaFile.exists()) {
          logger.severe("String_Node_Str");
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_IMAGEERROR);
          return step;
        }
        if ((captchaCode=Plugin.getCaptchaCode(captchaFile,this)) == null) {
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
          return step;
        }
        downloadurl="String_Node_Str" + steplink + "String_Node_Str"+ captchaCode;
        requestInfo=HTTP.getRequest((new URL(downloadurl)),downloadcookie,referrerurl,false);
        if (requestInfo.getLocation() != null && requestInfo.getLocation().contains("String_Node_Str")) {
          step.setStatus(PluginStep.STATUS_ERROR);
          downloadLink.setStatus(DownloadLink.STATUS_ERROR_CAPTCHA_WRONG);
          return step;
        }
        downloadcookie=downloadcookie + requestInfo.getCookie();
      }
      steplink=requestInfo.getRegexp("String_Node_Str").getFirstMatch();
      if (steplink == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
      downloadurl="String_Node_Str" + steplink;
      requestInfo=HTTP.getRequest(new URL(downloadurl),downloadcookie,referrerurl,false);
      if (requestInfo.getLocation() == null || requestInfo.getLocation().contains("String_Node_Str")) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
      downloadurl=requestInfo.getLocation();
      if (downloadurl == null) {
        downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
        step.setStatus(PluginStep.STATUS_ERROR);
        return step;
      }
    }
    downloadurl=downloadurl.replaceAll("String_Node_Str","String_Node_Str");
    requestInfo=HTTP.getRequestWithoutHtmlCode(new URL(downloadurl),requestInfo.getCookie(),referrerurl,false);
    HTTPConnection urlConnection=requestInfo.getConnection();
    String filename=getFileNameFormHeader(urlConnection);
    if (urlConnection.getContentLength() == 0) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_TEMPORARILY_UNAVAILABLE);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    downloadLink.setDownloadMax(urlConnection.getContentLength());
    downloadLink.setName(filename);
    long length=downloadLink.getDownloadMax();
    dl=new RAFDownload(this,downloadLink,urlConnection);
    dl.setChunkNum(1);
    dl.setResume(false);
    dl.setFilesize(length);
    if (!dl.startDownload() && step.getStatus() != PluginStep.STATUS_ERROR && step.getStatus() != PluginStep.STATUS_TODO) {
      downloadLink.setStatus(DownloadLink.STATUS_ERROR_TEMPORARILY_UNAVAILABLE);
      step.setStatus(PluginStep.STATUS_ERROR);
      return step;
    }
    return step;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  step.setStatus(PluginStep.STATUS_ERROR);
  downloadLink.setStatus(DownloadLink.STATUS_ERROR_UNKNOWN);
  return step;
}