Program: 109946
Project: 109946
Buggy source:
/** 
 * Posts a survey on Mechanical Turk using the current settings in MturkLibrary. Note that randomization is not performed here and so must be called before calling postSurvey. This also allows the user to not use randomization if she wishes.
 * @param survey
 * @return
 * @throws SurveyException
 * @throws ServiceException
 * @throws IOException
 */
public static List<HIT> postSurvey(Survey survey,Map<String,Integer> orderSeen) throws SurveyException, ServiceException, IOException, ParseException {
  Record record;
synchronized (ResponseManager.manager) {
    if (!ResponseManager.manager.containsKey(survey.sid)) {
      record=new Record(survey,(Properties)MturkLibrary.props.clone());
      ResponseManager.manager.put(survey.sid,record);
    }
 else {
      record=ResponseManager.manager.get(survey.sid);
    }
    if (record.hitTypeId == null || record.qualificationType == null)     ResponseManager.registerNewHitType(record);
  }
  List<HIT> hits=new ArrayList<HIT>();
  for (int i=numToBatch; i > 0; i--) {
    long lifetime=Long.parseLong(MturkLibrary.props.getProperty("String_Node_Str"));
    assert(record.hitTypeId != null);
    assert(record.qualificationType != null);
    String hitid=ResponseManager.createHIT(MturkLibrary.props.getProperty("String_Node_Str"),MturkLibrary.props.getProperty("String_Node_Str"),MturkLibrary.props.getProperty("String_Node_Str"),XML.getXMLString(survey),Double.parseDouble(MturkLibrary.props.getProperty("String_Node_Str")),Long.parseLong(MturkLibrary.props.getProperty("String_Node_Str")),ResponseManager.maxAutoApproveDelay,lifetime,ResponseManager.answerOnce(record),record.hitTypeId);
    HIT hit=ResponseManager.getHIT(hitid);
    System.out.println(SurveyPoster.makeHITURL(hit));
synchronized (ResponseManager.manager) {
      record.addNewHIT(hit);
      ResponseManager.manager.notifyAll();
    }
    hits.add(hit);
  }
  return hits;
}

Fixed version (ground truth):
/** 
 * Posts a survey on Mechanical Turk using the current settings in MturkLibrary. Note that randomization is not performed here and so must be called before calling postSurvey. This also allows the user to not use randomization if she wishes.
 * @param survey
 * @return
 * @throws SurveyException
 * @throws ServiceException
 * @throws IOException
 */
public static List<HIT> postSurvey(Survey survey) throws SurveyException, ServiceException, IOException, ParseException {
  Record record;
synchronized (ResponseManager.manager) {
    if (!ResponseManager.manager.containsKey(survey.sid)) {
      record=new Record(survey,(Properties)MturkLibrary.props.clone());
      ResponseManager.manager.put(survey.sid,record);
    }
 else {
      record=ResponseManager.manager.get(survey.sid);
    }
    if (record.hitTypeId == null || record.qualificationType == null)     ResponseManager.registerNewHitType(record);
  }
  List<HIT> hits=new ArrayList<HIT>();
  for (int i=numToBatch; i > 0; i--) {
    long lifetime=Long.parseLong(MturkLibrary.props.getProperty("String_Node_Str"));
    assert(record.hitTypeId != null);
    assert(record.qualificationType != null);
    String hitid=ResponseManager.createHIT(MturkLibrary.props.getProperty("String_Node_Str"),MturkLibrary.props.getProperty("String_Node_Str"),MturkLibrary.props.getProperty("String_Node_Str"),XML.getXMLString(survey),Double.parseDouble(MturkLibrary.props.getProperty("String_Node_Str")),Long.parseLong(MturkLibrary.props.getProperty("String_Node_Str")),ResponseManager.maxAutoApproveDelay,lifetime,ResponseManager.answerOnce(record),record.hitTypeId);
    HIT hit=ResponseManager.getHIT(hitid);
    System.out.println(SurveyPoster.makeHITURL(hit));
synchronized (ResponseManager.manager) {
      record.addNewHIT(hit);
      ResponseManager.manager.notifyAll();
    }
    hits.add(hit);
  }
  return hits;
}