Program: 109973
Project: 109973
Buggy source:
private void sendSurvey(){
  final Survey survey;
  final Thread runner, writer, notifier;
  try {
    JComboBox csvLabel=(JComboBox)componentMap.get("String_Node_Str");
    if (csvLabel != null) {
      String csv=(String)csvLabel.getSelectedItem();
      if (cachedSurveys.containsKey(csv))       survey=cachedSurveys.get(csv);
 else {
        survey=Experiment.makeSurvey();
        cachedSurveys.put(csv,survey);
      }
    }
 else     survey=null;
    runner=new Thread(){
      public void run(){
        boolean done=false;
        while (!done) {
          try {
            Runner.run(survey);
            done=true;
          }
 catch (          AccessKeyException ake) {
            Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
            (new File(MturkLibrary.CONFIG)).delete();
            SurveyMan.LOGGER.fatal(ake);
            System.exit(-1);
          }
catch (          SurveyException se) {
            SurveyMan.LOGGER.warn(se);
            Experiment.updateStatusLabel(String.format("String_Node_Str",se.getMessage()));
            done=true;
          }
catch (          ServiceException mturkse) {
            SurveyMan.LOGGER.warn(mturkse);
            Experiment.updateStatusLabel(String.format("String_Node_Str",mturkse.getMessage()));
          }
catch (          IOException io) {
            SurveyMan.LOGGER.warn(io);
            Experiment.updateStatusLabel(String.format("String_Node_Str",io.getMessage()));
            done=true;
          }
        }
      }
    }
;
    writer=new Thread(){
      public void run(){
        boolean notJoined=true;
        try {
          while (true) {
            ResponseManager.Record record=ResponseManager.getRecord(survey);
            if (record != null) {
              Runner.writeResponses(survey);
              if (!runner.isAlive() || !Runner.stillLive(survey)) {
                Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sourceName,record.responses.size(),record.outputFileName));
                cachedSurveys.remove(survey);
                break;
              }
              try {
                sleep(Runner.waitTime);
              }
 catch (              InterruptedException ie) {
                SurveyMan.LOGGER.warn(ie);
              }
            }
          }
        }
 catch (        AccessKeyException ake) {
          Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
          (new File(MturkLibrary.CONFIG)).delete();
          SurveyMan.LOGGER.fatal(ake);
          System.exit(-1);
        }
catch (        IOException io) {
          SurveyMan.LOGGER.warn(io);
          Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sid,survey.sourceName));
          boolean success=false;
          while (!success) {
            try {
              runner.join();
              ResponseManager.Record record=ResponseManager.getRecord(survey);
              for (              HIT hit : record.getAllHITs())               ResponseManager.expireHIT(hit);
              success=true;
            }
 catch (            InterruptedException ie) {
              SurveyMan.LOGGER.warn(ie);
            }
catch (            IOException ioe) {
              SurveyMan.LOGGER.warn(ioe);
            }
          }
        }
      }
    }
;
    notifier=new Thread(){
      public void run(){
        Map<String,HIT> hitsNotified=new HashMap<String,HIT>();
        Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sourceName));
        long waitTime=1000;
        while (runner.isAlive()) {
          try {
            while (ResponseManager.getRecord(survey) == null) {
              try {
                sleep(waitTime);
              }
 catch (              InterruptedException e) {
                SurveyMan.LOGGER.warn(e);
              }
            }
            while (ResponseManager.getRecord(survey).getLastHIT() == null) {
              try {
                sleep(waitTime);
              }
 catch (              InterruptedException e) {
                SurveyMan.LOGGER.warn(e);
              }
            }
            ResponseManager.Record record=ResponseManager.getRecord(survey);
            HIT hit=record.getLastHIT();
            if (!hitsNotified.containsKey(hit.getHITId())) {
              hitsNotified.put(hit.getHITId(),hit);
              Experiment.updateStatusLabel(String.format("String_Node_Str",hit.getHITId(),survey.sourceName));
            }
 else             waitTime=waitTime * (long)1.5;
          }
 catch (          AccessKeyException ake) {
            Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
            (new File(MturkLibrary.CONFIG)).delete();
            SurveyMan.LOGGER.fatal(ake);
            System.exit(-1);
          }
catch (          IOException io) {
            SurveyMan.LOGGER.warn(io);
          }
        }
      }
    }
;
    if (survey != null) {
      runner.setPriority(Thread.MIN_PRIORITY);
      writer.setPriority(Thread.MIN_PRIORITY);
      notifier.setPriority(Thread.MIN_PRIORITY);
      runner.start();
      writer.start();
      notifier.start();
    }
  }
 catch (  IOException e) {
    SurveyMan.LOGGER.warn(e);
    Experiment.updateStatusLabel(e.getMessage());
  }
catch (  SurveyException se) {
    SurveyMan.LOGGER.warn(se);
    Experiment.updateStatusLabel(String.format("String_Node_Str",se.getMessage()));
  }
catch (  ServiceException mturkse) {
    SurveyMan.LOGGER.warn(mturkse.getMessage());
    Experiment.updateStatusLabel(String.format("String_Node_Str",mturkse.getMessage()));
  }
}

Fixed version (ground truth):
private void sendSurvey(){
  final Survey survey;
  final Thread runner, writer, notifier;
  try {
    if (Experiment.csvLabel != null) {
      String csv=(String)Experiment.csvLabel.getSelectedItem();
      if (cachedSurveys.containsKey(csv))       survey=cachedSurveys.get(csv);
 else {
        survey=Experiment.makeSurvey();
        cachedSurveys.put(csv,survey);
      }
    }
 else     survey=null;
    runner=new Thread(){
      public void run(){
        boolean done=false;
        while (!done) {
          try {
            Runner.run(survey);
            done=true;
          }
 catch (          AccessKeyException ake) {
            Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
            (new File(MturkLibrary.CONFIG)).delete();
            SurveyMan.LOGGER.fatal(ake);
            System.exit(-1);
          }
catch (          SurveyException se) {
            SurveyMan.LOGGER.warn(se);
            Experiment.updateStatusLabel(String.format("String_Node_Str",se.getMessage()));
            done=true;
          }
catch (          ServiceException mturkse) {
            SurveyMan.LOGGER.warn(mturkse);
            Experiment.updateStatusLabel(String.format("String_Node_Str",mturkse.getMessage()));
          }
catch (          IOException io) {
            SurveyMan.LOGGER.warn(io);
            Experiment.updateStatusLabel(String.format("String_Node_Str",io.getMessage()));
            done=true;
          }
        }
      }
    }
;
    writer=new Thread(){
      public void run(){
        boolean notJoined=true;
        try {
          while (true) {
            ResponseManager.Record record=ResponseManager.getRecord(survey);
            if (record != null) {
              Runner.writeResponses(survey);
              if (!runner.isAlive() || !Runner.stillLive(survey)) {
                Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sourceName,record.responses.size(),record.outputFileName));
                cachedSurveys.remove(survey);
                break;
              }
              try {
                sleep(Runner.waitTime);
              }
 catch (              InterruptedException ie) {
                SurveyMan.LOGGER.warn(ie);
              }
            }
          }
        }
 catch (        AccessKeyException ake) {
          Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
          (new File(MturkLibrary.CONFIG)).delete();
          SurveyMan.LOGGER.fatal(ake);
          System.exit(-1);
        }
catch (        IOException io) {
          SurveyMan.LOGGER.warn(io);
          Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sid,survey.sourceName));
          boolean success=false;
          while (!success) {
            try {
              runner.join();
              ResponseManager.Record record=ResponseManager.getRecord(survey);
              for (              HIT hit : record.getAllHITs())               ResponseManager.expireHIT(hit);
              success=true;
            }
 catch (            InterruptedException ie) {
              SurveyMan.LOGGER.warn(ie);
            }
catch (            IOException ioe) {
              SurveyMan.LOGGER.warn(ioe);
            }
          }
        }
      }
    }
;
    notifier=new Thread(){
      public void run(){
        Map<String,HIT> hitsNotified=new HashMap<String,HIT>();
        Experiment.updateStatusLabel(String.format("String_Node_Str",survey.sourceName));
        long waitTime=1000;
        while (runner.isAlive()) {
          try {
            while (ResponseManager.getRecord(survey) == null) {
              try {
                sleep(waitTime);
              }
 catch (              InterruptedException e) {
                SurveyMan.LOGGER.warn(e);
              }
            }
            while (ResponseManager.getRecord(survey).getLastHIT() == null) {
              try {
                sleep(waitTime);
              }
 catch (              InterruptedException e) {
                SurveyMan.LOGGER.warn(e);
              }
            }
            ResponseManager.Record record=ResponseManager.getRecord(survey);
            HIT hit=record.getLastHIT();
            if (!hitsNotified.containsKey(hit.getHITId())) {
              hitsNotified.put(hit.getHITId(),hit);
              Experiment.updateStatusLabel(String.format("String_Node_Str",hit.getHITId(),survey.sourceName));
            }
 else             waitTime=waitTime * (long)1.5;
          }
 catch (          AccessKeyException ake) {
            Experiment.updateStatusLabel(String.format("String_Node_Str",ake.getMessage()));
            (new File(MturkLibrary.CONFIG)).delete();
            SurveyMan.LOGGER.fatal(ake);
            System.exit(-1);
          }
catch (          IOException io) {
            SurveyMan.LOGGER.warn(io);
          }
        }
      }
    }
;
    if (survey != null) {
      runner.setPriority(Thread.MIN_PRIORITY);
      writer.setPriority(Thread.MIN_PRIORITY);
      notifier.setPriority(Thread.MIN_PRIORITY);
      runner.start();
      writer.start();
      notifier.start();
    }
  }
 catch (  IOException e) {
    SurveyMan.LOGGER.warn(e);
    Experiment.updateStatusLabel(e.getMessage());
  }
catch (  SurveyException se) {
    SurveyMan.LOGGER.warn(se);
    Experiment.updateStatusLabel(String.format("String_Node_Str",se.getMessage()));
  }
catch (  ServiceException mturkse) {
    SurveyMan.LOGGER.warn(mturkse.getMessage());
    Experiment.updateStatusLabel(String.format("String_Node_Str",mturkse.getMessage()));
  }
}