nus-yam/ex-repair huggingface dataset:
Program: 109891
Project: 109891
Buggy source:
@Override public void onBackPressed(){
  if (fromAppChooser) {
    keyBackTouched=true;
    Intent intent=new Intent();
    intent.putExtra(AppManager.PACKAGE + "String_Node_Str","String_Node_Str");
    intent.putExtra("String_Node_Str",uri.toString());
    intent.setAction("String_Node_Str");
    intent.addCategory("String_Node_Str");
    startActivity(intent);
    onDestroy();
  }
  super.onBackPressed();
}

Fixed version (ground truth):
@Override public void onBackPressed(){
  if (fromAppChooser) {
    keyBackTouched=true;
    Intent intent=new Intent();
    intent.putExtra(AppManager.PACKAGE + "String_Node_Str","String_Node_Str");
    intent.putExtra("String_Node_Str",uri.toString());
    intent.putExtra("String_Node_Str",robotDescription.getRobotType());
    intent.putExtra("String_Node_Str",robotDescription.getRobotName());
    intent.setAction("String_Node_Str");
    intent.addCategory("String_Node_Str");
    startActivity(intent);
    onDestroy();
  }
  super.onBackPressed();
}
Program: 109892
Project: 109892
Buggy source:
/** 
 * Constructor for the QCMetrics instance.
 * @param survey The survey for which we want to compute metrics.
 * @param classifier The classifier we want to use for respondents.
 */
public QCMetrics(Survey survey,AbstractClassifier classifier){
}

Fixed version (ground truth):
/** 
 * Constructor for the QCMetrics instance.
 * @param survey The survey for which we want to compute metrics.
 * @param classifier The classifier we want to use for respondents.
 * @throws UnanalyzableException If the survey contains no analyzable questions (i.e., radio-button or check-boxquestions), then we throw this exception.
 */
public QCMetrics(Survey survey,AbstractClassifier classifier) throws SurveyException {
}
Program: 109893
Project: 109893
Buggy source:
/** 
 * Method to add a subblock to this block programmatically.
 * @param b The block we want to add as a subblock.
 * @throws SurveyException
 */
public void addBlock(Block b) throws SurveyException {
  if (this.branchParadigm.equals(BranchParadigm.ALL))   throw new BlockException("String_Node_Str");
 else {
    this.subBlocks.add(b);
  }
  edu.umass.cs.surveyman.analyses.rules.BranchParadigm.ensureBranchParadigms(this);
}

Fixed version (ground truth):
/** 
 * Method to add a subblock to this block programmatically.
 * @param b The block we want to add as a subblock.
 * @throws SurveyException
 */
public void addBlock(Block b) throws SurveyException {
  if (this.branchParadigm.equals(BranchParadigm.ALL))   throw new BlockException("String_Node_Str");
 else {
    this.subBlocks.add(b);
    b.parentBlock=this;
  }
  edu.umass.cs.surveyman.analyses.rules.BranchParadigm.ensureBranchParadigms(this);
}
Program: 109894
Project: 109894
Buggy source:
/** 
 * Sets the appropriate   {@link edu.umass.cs.surveyman.survey.Block.BranchParadigm} for this block and its ancestors.
 * @throws SurveyException
 */
private void propagateUp() throws SurveyException {
  if (parentBlock == null)   return;
switch (this.branchParadigm) {
case ONE:
switch (parentBlock.branchParadigm) {
case NONE:
      parentBlock.branchParadigm=this.branchParadigm;
    parentBlock.branchQ=this.branchQ;
  parentBlock.propagateUp();
break;
case ONE:
if (parentBlock.branchQ == null) parentBlock.branchQ=this.branchQ;
if (parentBlock.branchQ != null && !parentBlock.branchQ.equals(this.branchQ)) throw new BranchException(String.format("String_Node_Str",this.strId,this.parentBlock.strId,this.branchQ,this.parentBlock.branchQ));
break;
case ALL:
throw new BranchException(String.format("String_Node_Str",this.parentBlock.strId,this.strId));
}
case NONE:
break;
case ALL:
break;
}
}

Fixed version (ground truth):
/** 
 * Sets the appropriate   {@link edu.umass.cs.surveyman.survey.Block.BranchParadigm} for this block and its ancestors.
 * @throws SurveyException
 */
private void propagateUp() throws SurveyException {
}
Program: 109895
Project: 109895
Buggy source:
/** 
 * Sets the appropriate   {@link edu.umass.cs.surveyman.survey.Block.BranchParadigm} for all connected blocks.
 * @throws SurveyException
 */
public void propagateBranchParadigm() throws SurveyException {
  if (parentBlock == null)   return;
  if (branchParadigm.equals(BranchParadigm.ONE))   propagateUp();
  Block branchBlock=null;
  for (  Block b : parentBlock.subBlocks) {
switch (b.branchParadigm) {
case ONE:
      if (branchBlock != null)       throw new BlockException(String.format("String_Node_Str",parentBlock.strId,branchBlock.strId,b.strId));
 else {
        branchBlock=b;
        parentBlock.branchParadigm=BranchParadigm.ONE;
      }
    break;
case ALL:
  if (b.subBlocks.size() != 0)   throw new BlockException(String.format("String_Node_Str",b.strId,subBlocks.size()));
}
}
}

Fixed version (ground truth):
/** 
 * Sets the appropriate   {@link edu.umass.cs.surveyman.survey.Block.BranchParadigm} for all connected blocks.This method passes the branch paradigm up. It expects the branch paradigm for this current block to be set already. The method returns when it hits a top-level block. Since branch-all and branch-none classifications don't propagate up, this method only propagates branch-one, and asserts that its properties are not violated.
 * @throws SurveyException
 */
public void propagateBranchParadigm() throws SurveyException {
  if (parentBlock == null)   return;
  if (branchParadigm.equals(BranchParadigm.ONE))   propagateUp();
  for (  Block sibling : parentBlock.subBlocks) {
switch (sibling.branchParadigm) {
case ONE:
      if (!sibling.equals(this) && this.branchParadigm.equals(BranchParadigm.ONE))       throw new BlockException(String.format("String_Node_Str",parentBlock.strId,this.strId,sibling.strId));
    break;
case ALL:
  if (sibling.subBlocks.size() != 0)   throw new BlockException(String.format("String_Node_Str",sibling.strId,subBlocks.size()));
}
}
}
Program: 109896
Project: 109896
Buggy source:
/** 
 * Sets the branch destination of this question at the input option to the input destination. Adds the input option to this question's options, if it hasn't been added already. Resets the branch paradigm, if needed, and propagates the branch paradigm.
 * @param c The answer option whose branch destination we need to set.
 * @param dest The branch destination for the input answer option.
 * @throws SurveyException
 */
public void setBranchDest(SurveyDatum c,Block dest) throws SurveyException {
  if (!this.options.values().contains(c))   this.addOption(c);
  this.branchMap.put(c,dest);
  if (this.block.branchQ == null || !this.block.branchQ.equals(this)) {
    this.block.branchQ=this;
switch (this.block.branchParadigm) {
case NONE:
      this.block.updateBranchParadigm(Block.BranchParadigm.ONE);
    break;
case ONE:
  this.block.updateBranchParadigm(Block.BranchParadigm.ALL);
break;
}
}
this.block.propagateBranchParadigm();
}

Fixed version (ground truth):
/** 
 * Sets the branch destination of this question at the input option to the input destination. Adds the input option to this question's options, if it hasn't been added already. Resets the branch paradigm, if needed, and propagates the branch paradigm.
 * @param c The answer option whose branch destination we need to set.
 * @param dest The branch destination for the input answer option.
 * @throws SurveyException
 */
public void setBranchDest(SurveyDatum c,Block dest) throws SurveyException {
  if (!this.options.values().contains(c))   this.addOption(c);
  this.branchMap.put(c,dest);
  if (this.block.branchQ == null || !this.block.branchQ.equals(this)) {
    this.block.branchQ=this;
switch (this.block.branchParadigm) {
case NONE:
      this.block.updateBranchParadigm(Block.BranchParadigm.ONE);
    break;
case ONE:
  this.block.updateBranchParadigm(Block.BranchParadigm.ALL);
break;
}
}
}
Program: 109897
Project: 109897
Buggy source:
public void init(){
  block1=new Block("String_Node_Str");
  block2=new Block("String_Node_Str");
  block3=new Block("String_Node_Str");
  block4=new Block("String_Node_Str");
  branchQuestion1=Question.makeQuestion("String_Node_Str",1,1);
  a=new StringDatum("String_Node_Str",1,2,0);
  b=new StringDatum("String_Node_Str",2,2,1);
  branchQuestion2=Question.makeQuestion("String_Node_Str",3,1);
  c=new StringDatum("String_Node_Str",3,1,0);
  d=new StringDatum("String_Node_Str",4,1,1);
  noBranchQuestion1=Question.makeQuestion("String_Node_Str",5,1);
  noBranchQuestion2=Question.makeQuestion("String_Node_Str",6,1);
  survey=new Survey();
  try {
    branchQuestion1.addOption(a,block2);
    branchQuestion1.addOption(b,block4);
    block1.addBranchQuestion(branchQuestion1);
    branchQuestion2.addOption(c,block3);
    branchQuestion2.addOption(d,block4);
    block2.addBranchQuestion(branchQuestion2);
    block3.addQuestion(noBranchQuestion1);
    block4.addQuestion(noBranchQuestion2);
    survey.addBlock(block1);
    survey.addBlock(block2);
    survey.addBlock(block3);
    survey.addBlock(block4);
    StaticAnalysis.wellFormednessChecks(survey);
  }
 catch (  SurveyException e) {
    e.printStackTrace();
  }
  qcMetrics=new QCMetrics(survey,new StackedClassifier(survey,false,0.05,2));
}

Fixed version (ground truth):
public void init(){
  block1=new Block("String_Node_Str");
  block2=new Block("String_Node_Str");
  block3=new Block("String_Node_Str");
  block4=new Block("String_Node_Str");
  branchQuestion1=Question.makeQuestion("String_Node_Str",1,1);
  a=new StringDatum("String_Node_Str",1,2,0);
  b=new StringDatum("String_Node_Str",2,2,1);
  branchQuestion2=Question.makeQuestion("String_Node_Str",3,1);
  c=new StringDatum("String_Node_Str",3,1,0);
  d=new StringDatum("String_Node_Str",4,1,1);
  noBranchQuestion1=Question.makeQuestion("String_Node_Str",5,1);
  noBranchQuestion2=Question.makeQuestion("String_Node_Str",6,1);
  survey=new Survey();
  try {
    branchQuestion1.addOption(a,block2);
    branchQuestion1.addOption(b,block4);
    block1.addBranchQuestion(branchQuestion1);
    branchQuestion2.addOption(c,block3);
    branchQuestion2.addOption(d,block4);
    block2.addBranchQuestion(branchQuestion2);
    block3.addQuestion(noBranchQuestion1);
    block4.addQuestion(noBranchQuestion2);
    survey.addBlock(block1);
    survey.addBlock(block2);
    survey.addBlock(block3);
    survey.addBlock(block4);
    StaticAnalysis.wellFormednessChecks(survey);
    qcMetrics=new QCMetrics(survey);
  }
 catch (  SurveyException e) {
    e.printStackTrace();
  }
}
Program: 109899
Project: 109899
Buggy source:
protected static double chiSquared(int[][] contingencyTable,Object[] categoryA,Object[] categoryB){
  double testStatistic=0.0;
  int numSamples=0;
  for (int i=0; i < contingencyTable.length; i++)   for (int j=0; j < contingencyTable[i].length; j++)   numSamples+=contingencyTable[i][j];
  for (int r=0; r < categoryA.length; r++)   for (int c=0; c < categoryB.length; c++) {
    double eij=cellExpectation(contingencyTable,r,c,numSamples);
    if (eij == 0.0)     continue;
    testStatistic+=Math.pow(contingencyTable[r][c] - eij,2.0) / eij;
  }
  return testStatistic;
}

Fixed version (ground truth):
protected static double chiSquared(int[][] contingencyTable,Object[] categoryA,Object[] categoryB){
  double testStatistic=0.0;
  int numSamples=0;
  for (  int[] aContingencyTable : contingencyTable)   for (  int anAContingencyTable : aContingencyTable)   numSamples+=anAContingencyTable;
  for (int r=0; r < categoryA.length; r++)   for (int c=0; c < categoryB.length; c++) {
    double eij=cellExpectation(contingencyTable,r,c,numSamples);
    if (eij == 0.0)     continue;
    testStatistic+=Math.pow(contingencyTable[r][c] - eij,2.0) / eij;
  }
  return testStatistic;
}
Program: 109900
Project: 109900
Buggy source:
/** 
 * Returns paths through **blocks** in the survey. Top level randomized blocks are all listed last
 * @param s The survey whose paths we want to enumerate
 * @return A List of all paths through the survey. A path is represented by a List. There may be duplicate paths,so if you need distinct paths, you will need to filter for uniqueness.
 */
protected static List<Set<Block>> getPaths(Survey s){
  List<Set<Block>> retval=new ArrayList<>();
  Map<Boolean,List<Block>> partitionedBlocks=Interpreter.partitionBlocks(s);
  List<Block> topLevelRandomizableBlocks=partitionedBlocks.get(true);
  List<Block> nonrandomizableBlocks=partitionedBlocks.get(false);
  Collections.sort(nonrandomizableBlocks);
  List<List<Block>> dag=getDag(nonrandomizableBlocks);
  SurveyMan.LOGGER.info("String_Node_Str" + dag.size() + "String_Node_Str");
  if (dag.size() == 1 && dag.get(0).isEmpty()) {
    retval.add(new HashSet<>(topLevelRandomizableBlocks));
    return retval;
  }
  for (  List<Block> blist : dag) {
    if (blist.isEmpty())     continue;
    blist.addAll(topLevelRandomizableBlocks);
    retval.add(new HashSet<>(blist));
  }
  if (retval.size() > 1)   SurveyMan.LOGGER.info(String.format("String_Node_Str",retval.size()));
  return retval;
}

Fixed version (ground truth):
/** 
 * Returns paths through **blocks** in the survey. Top level randomized blocks are all listed last
 * @param s The survey whose paths we want to enumerate
 * @return A List of all paths through the survey. A path is represented by a List. There may be duplicate paths,so if you need distinct paths, you will need to filter for uniqueness.
 */
protected static List<Set<Block>> getPaths(Survey s){
}
Program: 109901
Project: 109901
Buggy source:
public StaticAnalysisServer(int port){
  this.server=new Server(port);
  this.server.setHandler(new AbstractHandler(){
    @Override public void handle(    String target,    Request baseRequest,    HttpServletRequest request,    HttpServletResponse response) throws IOException, ServletException {
      baseRequest.setHandled(true);
      try {
        response.addHeader("String_Node_Str","String_Node_Str");
        analyzeRequest(request,response);
      }
 catch (      SurveyException e) {
        e.printStackTrace();
        response.sendError(400,"String_Node_Str" + e.getMessage());
      }
catch (      Exception e) {
        e.printStackTrace();
        System.out.println("String_Node_Str");
        response.sendError(501,e.getMessage());
      }
    }
  }
);
}

Fixed version (ground truth):
public StaticAnalysisServer(int port){
  this.server=new Server(port);
  this.server.setHandler(new AbstractHandler(){
    @Override public void handle(    String target,    Request baseRequest,    HttpServletRequest request,    HttpServletResponse response) throws IOException, ServletException {
      baseRequest.setHandled(true);
      try {
        response.addHeader("String_Node_Str","String_Node_Str");
        response.addHeader("String_Node_Str","String_Node_Str");
        response.addHeader("String_Node_Str","String_Node_Str");
        analyzeRequest(request,response);
      }
 catch (      SurveyException e) {
        e.printStackTrace();
        response.sendError(400,"String_Node_Str" + e.getMessage());
      }
catch (      Exception e) {
        e.printStackTrace();
        System.out.println("String_Node_Str");
        response.sendError(501,e.getMessage());
      }
    }
  }
);
}
Program: 109902
Project: 109902
Buggy source:
@Override public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  baseRequest.setHandled(true);
  try {
    response.addHeader("String_Node_Str","String_Node_Str");
    analyzeRequest(request,response);
  }
 catch (  SurveyException e) {
    e.printStackTrace();
    response.sendError(400,"String_Node_Str" + e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    System.out.println("String_Node_Str");
    response.sendError(501,e.getMessage());
  }
}

Fixed version (ground truth):
@Override public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
  baseRequest.setHandled(true);
  try {
    response.addHeader("String_Node_Str","String_Node_Str");
    response.addHeader("String_Node_Str","String_Node_Str");
    response.addHeader("String_Node_Str","String_Node_Str");
    analyzeRequest(request,response);
  }
 catch (  SurveyException e) {
    e.printStackTrace();
    response.sendError(400,"String_Node_Str" + e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    System.out.println("String_Node_Str");
    response.sendError(501,e.getMessage());
  }
}
Program: 109904
Project: 109904
Buggy source:
public double responseToDouble(List<OptTuple> opts,boolean noise) throws SurveyException {
}

Fixed version (ground truth):
/** 
 * Converts a response to a double precision representation, for use in clustering.
 * @param opts The answer set to this question.
 * @param noise Boolean indicating whether we should add noise.
 * @return
 * @throws SurveyException
 */
public double responseToDouble(List<OptTuple> opts,boolean noise) throws SurveyException {
}
Program: 109905
Project: 109905
Buggy source:
public DynamicSurveyResponse(Survey survey,String srid){
  super(survey);
  this.setSrid(srid);
}

Fixed version (ground truth):
public DynamicSurveyResponse(SurveyResponse surveyResponse){
  super(surveyResponse.getSurvey(),surveyResponse.getAllResponses(),surveyResponse.getSrid(),surveyResponse.getScore(),surveyResponse.getThreshold(),surveyResponse.getKnownValidityStatus());
}
Program: 109906
Project: 109906
Buggy source:
public static Report dynamicAnalysis(Survey survey,List<DynamicSurveyResponse> responses,Classifier classifier,boolean smoothing,double alpha) throws SurveyException {
  return new Report(survey.sourceName,survey.sid,alpha,smoothing,QCMetrics.calculateOrderBiases(survey,responses,alpha),QCMetrics.calculateWordingBiases(survey,responses,alpha),QCMetrics.calculateBreakoffByPosition(survey,responses),QCMetrics.calculateBreakoffByQuestion(survey,responses),QCMetrics.classifyResponses(survey,responses,classifier,smoothing,alpha));
}

Fixed version (ground truth):
public static Report dynamicAnalysis(Survey survey,List<DynamicSurveyResponse> responses,Classifier classifier,boolean smoothing,double alpha) throws SurveyException {
  return new Report(survey.sourceName,survey.sid,alpha,smoothing,OrderBias.calculateOrderBiases(survey,responses,alpha),QCMetrics.calculateWordingBiases(survey,responses,alpha),QCMetrics.calculateBreakoffByPosition(survey,responses),QCMetrics.calculateBreakoffByQuestion(survey,responses),QCMetrics.classifyResponses(survey,responses,classifier,smoothing,alpha));
}
Program: 109907
Project: 109907
Buggy source:
public CorrelationStruct(CoefficentsAndTests coefficientType,double coefficientValue,Question thingA,Question thingB,int numSamplesA,int numSamplesB){
  this.coefficientType=coefficientType;
  this.coefficientValue=coefficientValue;
  this.thingA=thingA;
  this.thingB=thingB;
  this.numSamplesA=numSamplesA;
  this.numSamplesB=numSamplesB;
}

Fixed version (ground truth):
public CorrelationStruct(CoefficentsAndTests coefficientType,double coefficientValue,double coefficientPValue,Question thingA,Question thingB,int numSamplesA,int numSamplesB){
  this.coefficientType=coefficientType;
  this.coefficientValue=coefficientValue;
  this.coefficientPValue=coefficientPValue;
  this.thingA=thingA;
  this.thingB=thingB;
  this.numSamplesA=numSamplesA;
  this.numSamplesB=numSamplesB;
}
Program: 109908
Project: 109908
Buggy source:
public OrderBiasStruct(Survey survey,double alpha){
  this.alpha=alpha;
  for (  Question q1 : survey.questions) {
    this.biases.put(q1,new HashMap<Question,CorrelationStruct>());
    for (    Question q2 : survey.questions)     this.biases.get(q1).put(q2,null);
  }
}

Fixed version (ground truth):
public OrderBiasStruct(Survey survey,double alpha){
  this.alpha=alpha;
  for (int i=0; i < survey.questions.size() - 1; i++) {
    Question q1=survey.questions.get(i);
    this.biases.put(q1,new HashMap<Question,CorrelationStruct>());
    for (int j=i + 1; j < survey.questions.size(); j++) {
      Question q2=survey.questions.get(j);
      this.biases.get(q1).put(q2,null);
    }
  }
}
Program: 109909
Project: 109909
Buggy source:
private boolean flagCondition(CorrelationStruct struct){
  double ratio=struct.numSamplesA / (double)struct.numSamplesB;
  return struct.coefficientValue > 0.0 && struct.coefficientValue < this.alpha && struct.numSamplesA > minSamples && struct.numSamplesB > minSamples && ratio > 1.0 - ratioRange && ratio < 1.0 + ratioRange;
}

Fixed version (ground truth):
private boolean flagCondition(CorrelationStruct struct){
  double ratio=struct.numSamplesA / (double)struct.numSamplesB;
  return struct.coefficientPValue > 0.0 && struct.coefficientPValue < this.alpha && struct.numSamplesA > minSamples && struct.numSamplesB > minSamples && ratio > 1.0 - ratioRange && ratio < 1.0 + ratioRange;
}
Program: 109910
Project: 109910
Buggy source:
@Override public String toString(){
  List<String> biases=new ArrayList<String>();
  for (  Question q1 : this.biases.keySet()) {
    for (    Question q2 : this.biases.get(q1).keySet()) {
      CorrelationStruct structs=this.biases.get(q1).get(q2);
      if (structs == null)       continue;
      String data=String.format("String_Node_Str",q1.data,q2.data,structs.coefficientType.name(),structs.coefficientValue,structs.numSamplesA,structs.numSamplesB);
      SurveyMan.LOGGER.debug(data);
      if (flagCondition(structs))       biases.add(data);
    }
  }
  return "String_Node_Str" + "String_Node_Str" + StringUtils.join(biases,"String_Node_Str") + "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  List<String> biases=new ArrayList<>();
  for (  Question q1 : this.biases.keySet()) {
    for (    Question q2 : this.biases.get(q1).keySet()) {
      CorrelationStruct structs=this.biases.get(q1).get(q2);
      if (structs == null)       continue;
      String data=String.format("String_Node_Str",q1.data,q2.data,structs.coefficientType.name(),structs.coefficientValue,structs.coefficientPValue,structs.numSamplesA,structs.numSamplesB);
      if (flagCondition(structs))       biases.add(data);
    }
  }
  return "String_Node_Str" + "String_Node_Str" + this.numImbalances + "String_Node_Str"+ "String_Node_Str"+ this.numComparisons+ "String_Node_Str"+ "String_Node_Str"+ StringUtils.join(biases,"String_Node_Str")+ "String_Node_Str";
}
Program: 109911
Project: 109911
Buggy source:
/** 
 * Returns the next question, according to the status of the interpreter.
 * @return The next question that needs to be answered.
 * @throws SurveyException
 */
public Question getNextQuestion() throws SurveyException {
  Question next=nextQ();
  SurveyDatum[] options=next.getOptListByIndex();
  if (next.randomize)   if (next.ordered) {
    if (random.nextBoolean())     for (int i=0; i < options.length / 2; i++) {
      SurveyDatum foo=options[i];
      options[i]=options[options.length - i - 1];
      options[options.length - i - 1]=foo;
    }
  }
 else {
    List<SurveyDatum> stuff=Arrays.asList(options);
    Collections.shuffle(stuff);
    options=stuff.toArray(options);
  }
  for (int i=0; i < options.length; i++)   options[i].setIndex(i);
  return next;
}

Fixed version (ground truth):
/** 
 * Returns the next question, according to the status of the interpreter.
 * @return The next question that needs to be answered.
 * @throws SurveyException
 */
public Question getNextQuestion() throws SurveyException {
  Question next=nextQ();
  SurveyDatum[] options=next.getOptListByIndex();
  if (next.randomize)   if (next.ordered) {
    if (random.nextBoolean())     for (int i=0; i < options.length / 2; i++) {
      SurveyDatum foo=options[i];
      options[i]=options[options.length - i - 1];
      options[options.length - i - 1]=foo;
    }
  }
 else {
    random.shuffle(options);
  }
  for (int i=0; i < options.length; i++)   options[i].setIndex(i);
  return next;
}
Program: 109913
Project: 109913
Buggy source:
/** 
 * Answers question q with some list of answers.
 * @param q Question of interest.
 * @param aList List of components (i.e., valid answer(s) to the input question) .
 * @throws SurveyException
 */
public void answer(Question q,List<SurveyDatum> aList) throws SurveyException {
  responseMap.put(q,aList);
  if (q.isBranchQuestion()) {
    branchTo=q.getBranchDest(aList.get(0));
  }
}

Fixed version (ground truth):
/** 
 * Answers question q with some list of answers.
 * @param q Question of interest.
 * @param aList List of components (i.e., valid answer(s) to the input question) .
 * @throws SurveyException
 */
public void answer(Question q,List<SurveyDatum> aList) throws SurveyException {
  responseMap.put(q,aList);
  questionList.add(q);
  if (q.isBranchQuestion()) {
    branchTo=q.getBranchDest(aList.get(0));
  }
}
Program: 109914
Project: 109914
Buggy source:
@Override public int getIndexSeen(){
  return questions.indexOf(e.getKey());
}

Fixed version (ground truth):
@Override public int getIndexSeen(){
  return questionList.indexOf(e.getKey());
}
Program: 109915
Project: 109915
Buggy source:
private void unifyBranching(Survey survey,JsonArray jsonBlocks) throws BranchException {
  for (  JsonElement e : jsonBlocks) {
    JsonObject block=e.getAsJsonObject();
    if (block.has("String_Node_Str")) {
      for (      JsonElement qs : block.getAsJsonArray("String_Node_Str")) {
        JsonObject q=qs.getAsJsonObject();
        if (q.has("String_Node_Str")) {
          String jsonId=q.get("String_Node_Str").getAsString();
          Question question=findQuestion(survey.questions,internalIdMap.get(jsonId));
          for (          Map.Entry<String,JsonElement> ee : q.get("String_Node_Str").getAsJsonObject().entrySet())           question.addOption(question.options.get(ee.getKey()),this.internalBlockLookup.get(ee.getValue().getAsString()));
          if (question.block.branchQ == null) {
            question.block.branchParadigm=Block.BranchParadigm.ONE;
            question.block.branchQ=question;
          }
 else           if (question.block.branchQ != question) {
            question.block.branchParadigm=Block.BranchParadigm.ALL;
          }
        }
      }
    }
    if (block.has("String_Node_Str")) {
      unifyBranching(survey,block.get("String_Node_Str").getAsJsonArray());
    }
  }
}

Fixed version (ground truth):
private void unifyBranching(Survey survey,JsonArray jsonBlocks) throws SurveyException {
  for (  JsonElement e : jsonBlocks) {
    JsonObject block=e.getAsJsonObject();
    if (block.has("String_Node_Str")) {
      for (      JsonElement qs : block.getAsJsonArray("String_Node_Str")) {
        JsonObject q=qs.getAsJsonObject();
        if (q.has("String_Node_Str")) {
          String jsonQuestionId=q.get("String_Node_Str").getAsString();
          Question question=findQuestion(survey.questions,internalIdMap.get(jsonQuestionId));
          for (          Map.Entry<String,JsonElement> ee : q.get("String_Node_Str").getAsJsonObject().entrySet()) {
            String jsonOptionId=ee.getKey();
            String jsonBlockId=ee.getValue().getAsString();
            if (jsonBlockId.equals(Block.NEXT))             continue;
            Component opt=findOption(question,internalIdMap.get(jsonOptionId));
            Block dest=findBlock(jsonBlockId);
            question.addOption(opt,dest);
          }
          if (question.block.branchQ == null) {
            question.block.branchParadigm=Block.BranchParadigm.ONE;
            question.block.branchQ=question;
          }
 else           if (question.block.branchQ != question) {
            question.block.branchParadigm=Block.BranchParadigm.ALL;
          }
        }
      }
    }
    if (block.has("String_Node_Str")) {
      unifyBranching(survey,block.get("String_Node_Str").getAsJsonArray());
    }
  }
}
Program: 109916
Project: 109916
Buggy source:
private Component makeComponent(JsonObject option,int r){
  String data=option.get("String_Node_Str").getAsString();
  if (HTMLComponent.isHTMLComponent(data))   return new HTMLComponent(data,r,OPTION_COL);
 else   return new StringComponent(data,r,OPTION_COL);
}

Fixed version (ground truth):
private Component makeComponent(JsonObject option,int r){
  String data=option.get("String_Node_Str").getAsString();
  String id=option.get("String_Node_Str").getAsString();
  Component c;
  if (HTMLComponent.isHTMLComponent(data))   c=new HTMLComponent(data,r,OPTION_COL);
 else   c=new StringComponent(data,r,OPTION_COL);
  internalIdMap.put(id,c.getCid());
  return c;
}
Program: 109917
Project: 109917
Buggy source:
/** 
 * Returns the maximum possible entropy for a single Question.
 * @param question
 * @return
 */
private static double maxEntropyOneQuestion(Question question){
  double retval=0.0;
  int numOptions=question.options.size();
  if (numOptions != 0) {
    retval+=Math.log((double)numOptions) / Math.log(2.0);
  }
  return retval;
}

Fixed version (ground truth):
/** 
 * Returns the maximum possible entropy for a single Question.
 * @param question
 * @return
 */
private static double maxEntropyOneQuestion(Question question){
  double retval=0.0;
  int numOptions=question.options.size();
  if (numOptions != 0) {
    retval+=log2((double)numOptions);
  }
  return retval;
}
Program: 109918
Project: 109918
Buggy source:
public static double surveyEntropy(Survey s,List<ISurveyResponse> responses){
  List<List<Block>> paths=getPaths(s);
  Map<List<Block>,List<ISurveyResponse>> pathMap=makeFrequenciesForPaths(paths,responses);
  int totalResponses=responses.size();
  double retval=0.0;
  for (  Question q : removeFreetext(s.questions)) {
    for (    Component c : q.options.values()) {
      for (      List<Block> path : paths) {
        List<Component> variants=getEquivalentAnswerVariants(q,c);
        List<ISurveyResponse> responsesThisPath=pathMap.get(path);
        List<ISurveyResponse> ansThisPath=new ArrayList<ISurveyResponse>();
        for (        ISurveyResponse r : responsesThisPath) {
          if (r.surveyResponseContainsAnswer(variants)) {
            ansThisPath.add(r);
          }
        }
        double p=ansThisPath.size() / (double)totalResponses;
        retval+=(Math.log(p) / Math.log(2.0)) * p;
      }
    }
  }
  return -retval;
}

Fixed version (ground truth):
public static double surveyEntropy(Survey s,List<ISurveyResponse> responses){
  List<List<Block>> paths=getPaths(s);
  Map<List<Block>,List<ISurveyResponse>> pathMap=makeFrequenciesForPaths(paths,responses);
  int totalResponses=responses.size();
  double retval=0.0;
  for (  Question q : removeFreetext(s.questions)) {
    for (    Component c : q.options.values()) {
      for (      List<Block> path : paths) {
        List<Component> variants=getEquivalentAnswerVariants(q,c);
        List<ISurveyResponse> responsesThisPath=pathMap.get(path);
        List<ISurveyResponse> ansThisPath=new ArrayList<ISurveyResponse>();
        for (        ISurveyResponse r : responsesThisPath) {
          if (r.surveyResponseContainsAnswer(variants)) {
            ansThisPath.add(r);
          }
        }
        double p=ansThisPath.size() / (double)totalResponses;
        retval+=log2(p) * p;
      }
    }
  }
  return -retval;
}
Program: 109919
Project: 109919
Buggy source:
public static double getLLForResponse(ISurveyResponse surveyResponse,Map<String,Map<String,Double>> probabilities){
  double ll=0.0;
  for (  IQuestionResponse questionResponse : surveyResponse.getResponses()) {
    String qid=questionResponse.getQuestion().quid;
    for (    String cid : OptTuple.getCids(questionResponse.getOpts())) {
      ll+=Math.log(probabilities.get(qid).get(cid)) / Math.log(2.0);
    }
  }
  return ll;
}

Fixed version (ground truth):
public static double getLLForResponse(ISurveyResponse surveyResponse,Map<String,Map<String,Double>> probabilities){
  double ll=0.0;
  for (  IQuestionResponse questionResponse : surveyResponse.getResponses()) {
    String qid=questionResponse.getQuestion().quid;
    for (    String cid : OptTuple.getCids(questionResponse.getOpts())) {
      ll+=log2(probabilities.get(qid).get(cid));
    }
  }
  return ll;
}
Program: 109920
Project: 109920
Buggy source:
@Test public void testParse() throws Exception {
  String[] jsonExamples=Slurpie.slurp("String_Node_Str").split("String_Node_Str");
  for (  String f : jsonExamples) {
    JSONParser parser=JSONParser.makeParser(f);
    Survey s=parser.parse();
    LOGGER.debug("String_Node_Str" + s.toString());
  }
}

Fixed version (ground truth):
@Test public void testParse() throws Exception {
  String[] jsonExamples=Slurpie.slurp("String_Node_Str").split("String_Node_Str");
  LOGGER.info(String.format("String_Node_Str",Arrays.toString(jsonExamples)));
  for (  String f : jsonExamples) {
    LOGGER.debug(String.format("String_Node_Str",f));
    JSONParser parser=JSONParser.makeParser(f);
    LOGGER.debug(String.format("String_Node_Str",f));
    Survey s=parser.parse();
    LOGGER.debug("String_Node_Str" + s.toString());
  }
}
Program: 109921
Project: 109921
Buggy source:
@Test public void testNonRandomRespondentFrequencies(){
  AbstractRespondent profile=new NonRandomRespondent(survey);
  List<ISurveyResponse> responses=new ArrayList<ISurveyResponse>();
  for (int i=0; i < 10; i++) {
    responses.add(profile.getResponse());
  }
}

Fixed version (ground truth):
@Test public void testNonRandomRespondentFrequencies(){
}
Program: 109922
Project: 109922
Buggy source:
private String[] getHeaders(Reader reader) throws SurveyException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
  Gensym gensym=new Gensym("String_Node_Str");
  boolean hasQuestion=false, hasOption=false;
  CsvPreference pref;
  if (this.sep.equals("String_Node_Str"))   pref=CsvPreference.EXCEL_PREFERENCE;
 else   if (this.sep.equals("String_Node_Str") || this.sep.equals("String_Node_Str") || this.sep.equals("String_Node_Str"))   pref=CsvPreference.TAB_PREFERENCE;
 else   throw new SyntaxException("String_Node_Str" + this.sep);
  CsvListReader csvListReader=new CsvListReader(reader,pref);
  List<String> line=csvListReader.read();
  String[] headers=mapStringOp(line.toArray(new String[line.size()]),String.class.getMethod("String_Node_Str"));
  headers=mapStringOp(headers,String.class.getMethod("String_Node_Str"));
  for (int i=0; i < headers.length; i++) {
    if (headers[i].equals(AbstractParser.QUESTION))     hasQuestion=true;
    if (headers[i].equals(AbstractParser.OPTIONS))     hasOption=true;
    if (headers[i].equals("String_Node_Str"))     headers[i]=gensym.next();
  }
  if (!hasQuestion || !hasOption)   throw new HeaderException(String.format("String_Node_Str",hasQuestion ? AbstractParser.OPTIONS : AbstractParser.QUESTION,this.filename,sep));
  return headers;
}

Fixed version (ground truth):
private int getHeaders(Reader reader) throws SurveyException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
}
Program: 109923
Project: 109923
Buggy source:
private CellProcessor[] makeProcessors() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
  CellProcessor[] cellProcessors=new CellProcessor[headers.length];
  String[] truthValues=new String[(trueValues.length + falseValues.length) * 2];
  Method upperCase=String.class.getMethod("String_Node_Str");
  System.arraycopy(trueValues,0,truthValues,0,trueValues.length);
  System.arraycopy(falseValues,0,truthValues,trueValues.length,falseValues.length);
  System.arraycopy(mapStringOp(trueValues,upperCase),0,truthValues,trueValues.length + falseValues.length,trueValues.length);
  System.arraycopy(mapStringOp(falseValues,upperCase),0,truthValues,(trueValues.length * 2) + falseValues.length,falseValues.length);
  for (int i=0; i < headers.length; i++) {
    String header=headers[i];
    if (header.equals(AbstractParser.BLOCK))     cellProcessors[i]=new Optional(new StrRegEx("String_Node_Str"));
 else     if (header.equals(AbstractParser.BRANCH))     cellProcessors[i]=new Optional(new StrRegEx("String_Node_Str"));
 else     if (header.equals(AbstractParser.EXCLUSIVE) || headers[i].equals(AbstractParser.ORDERED) || headers[i].equals(AbstractParser.RANDOMIZE))     cellProcessors[i]=new Optional(new IsIncludedIn(truthValues));
 else     cellProcessors[i]=new Optional();
  }
  return cellProcessors;
}

Fixed version (ground truth):
private CellProcessor[] makeProcessors() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
}
Program: 109924
Project: 109924
Buggy source:
@Test public void testNonRandomRespondent() throws InvocationTargetException, SurveyException, IllegalAccessException, NoSuchMethodException, IOException {
  LOGGER.info("String_Node_Str");
  Survey survey=new CSVParser(new CSVLexer(super.testsFiles[0],String.valueOf(super.separators[0]))).parse();
  AbstractRespondent profile=new NonRandomRespondent(survey);
  ISurveyResponse sr1=profile.getResponse();
  ISurveyResponse sr2=profile.getResponse();
  List<ISurveyResponse> srs=new ArrayList<ISurveyResponse>();
  srs.add(sr1);
  srs.add(sr2);
  Map<String,Map<String,Double>> probs=QCMetrics.makeProbabilities(QCMetrics.makeFrequencies(srs));
  double ll1=QCMetrics.getLLForResponse(sr1,probs);
  double ll2=QCMetrics.getLLForResponse(sr2,probs);
  LOGGER.debug(String.format("String_Node_Str",ll1,ll2));
}

Fixed version (ground truth):
@Test public void testNonRandomRespondent() throws InvocationTargetException, SurveyException, IllegalAccessException, NoSuchMethodException, IOException {
}
Program: 109925
Project: 109925
Buggy source:
public static double averagePathLength(Survey survey) throws SurveyException {
  double lengthSum=0.0;
  for (int i=0; i < 5000; i++) {
    System.out.println(lengthSum);
    lengthSum+=new RandomRespondent(survey,RandomRespondent.AdversaryType.UNIFORM).response.responses.size();
  }
  return lengthSum / 5000.0;
}

Fixed version (ground truth):
public static double averagePathLength(Survey survey) throws SurveyException {
  double lengthSum=0.0;
  for (int i=0; i < 5000; i++) {
    lengthSum+=new RandomRespondent(survey,RandomRespondent.AdversaryType.UNIFORM).response.responses.size();
  }
  return lengthSum / 5000.0;
}
Program: 109926
Project: 109926
Buggy source:
private void populateResponses() throws SurveyException {
  Interpreter interpreter=new Interpreter(survey);
  do {
    Question q=interpreter.getNextQuestion();
    Component[] c=q.getOptListByIndex();
    List<Component> answers=new ArrayList<Component>();
    int denom=getDenominator(q);
    if (q.freetext || denom < 1) {
      answers.add(new StringComponent("String_Node_Str",-1,-1));
    }
 else {
      double prob=rng.nextDouble();
      double cumulativeProb=0.0;
      for (int j=0; j < denom; j++) {
        cumulativeProb+=posPref.get(q)[j];
        if (prob < cumulativeProb) {
          answers.addAll(selectOptions(j,c));
        }
      }
    }
    interpreter.answer(q,answers);
  }
 while (!interpreter.terminated());
  this.response=interpreter.getResponse();
}

Fixed version (ground truth):
private void populateResponses() throws SurveyException {
}
Program: 109927
Project: 109927
Buggy source:
private List<Component> selectOptions(int i,Component[] options){
  List<Component> retval=new ArrayList<Component>();
  if (i > options.length) {
    int j=0;
    for (    char c : Integer.toBinaryString(i).toCharArray()) {
      if (c == '1')       retval.add(options[j]);
      j++;
    }
  }
 else   retval.add(options[i]);
  return retval;
}

Fixed version (ground truth):
private List<Component> selectOptions(int i,Component[] options){
}
Program: 109928
Project: 109928
Buggy source:
private int resetQuestionIndices(Block b,int startingIndex){
  System.out.println("String_Node_Str" + b.strId + "String_Node_Str"+ startingIndex);
  int index=startingIndex;
  for (  Question q : b.questions) {
    q.index=index;
    index++;
  }
  for (  Block bb : b.subBlocks) {
    System.out.println(String.format("String_Node_Str",b.strId,bb.strId,index));
    index+=resetQuestionIndices(bb,index);
  }
  System.out.println(String.format("String_Node_Str",b.strId,b.blockSize()));
  return b.blockSize();
}

Fixed version (ground truth):
private int resetQuestionIndices(Block b,int startingIndex){
  LOGGER.info("String_Node_Str" + b.strId + "String_Node_Str"+ startingIndex);
  int index=startingIndex;
  for (  Question q : b.questions) {
    q.index=index;
    index++;
  }
  for (  Block bb : b.subBlocks) {
    LOGGER.info(String.format("String_Node_Str",b.strId,bb.strId,index));
    index+=resetQuestionIndices(bb,index);
  }
  LOGGER.info(String.format("String_Node_Str",b.strId,b.blockSize()));
  return b.blockSize();
}
Program: 109929
Project: 109929
Buggy source:
public static String getHTMLString(Survey survey,system.interfaces.HTML backendHTML) throws SurveyException {
  String html="String_Node_Str";
  try {
    if (ResponseManager.getRecord(survey) == null)     ResponseManager.putRecord(survey,new Library(),BackendType.LOCALHOST);
    Record record=ResponseManager.getRecord(survey);
    assert(record != null);
    assert(record.library != null);
    assert(record.library.props != null);
    Component preview=CSVParser.parseComponent(record.library.props.getProperty("String_Node_Str","String_Node_Str"),-1,-1);
    System.out.println(backendHTML.getClass().getName());
    html=String.format(Slurpie.slurp(Library.HTMLSKELETON),survey.encoding,JS.getJSString(survey,preview),stringifyPreview(preview),stringify(),backendHTML.getActionForm(record),survey.source,record.outputFileName,backendHTML.getHTMLString(),Slurpie.slurp(Library.CUSTOMCSS,true));
  }
 catch (  FileNotFoundException ex) {
    LOGGER.fatal(ex);
    System.exit(-1);
  }
catch (  IOException ex) {
    LOGGER.fatal(ex);
    System.exit(-1);
  }
  try {
    spitHTMLToFile(html,survey);
  }
 catch (  IOException io) {
    LOGGER.warn(io);
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
  return (new HtmlCompressor()).compress(html);
}

Fixed version (ground truth):
public static String getHTMLString(Survey survey,system.interfaces.HTML backendHTML) throws SurveyException {
  String html="String_Node_Str";
  try {
    if (ResponseManager.getRecord(survey) == null)     ResponseManager.putRecord(survey,new Library(),BackendType.LOCALHOST);
    Record record=ResponseManager.getRecord(survey);
    assert(record != null);
    assert(record.library != null);
    assert(record.library.props != null);
    Component preview=CSVParser.parseComponent(record.library.props.getProperty("String_Node_Str","String_Node_Str"),-1,-1);
    html=String.format(Slurpie.slurp(Library.HTMLSKELETON),survey.encoding,JS.getJSString(survey,preview),stringifyPreview(preview),stringify(),backendHTML.getActionForm(record),survey.source,record.outputFileName,backendHTML.getHTMLString(),Slurpie.slurp(Library.CUSTOMCSS,true));
  }
 catch (  FileNotFoundException ex) {
    LOGGER.fatal(ex);
    System.exit(-1);
  }
catch (  IOException ex) {
    LOGGER.fatal(ex);
    System.exit(-1);
  }
  try {
    spitHTMLToFile(html,survey);
  }
 catch (  IOException io) {
    LOGGER.warn(io);
  }
catch (  InstantiationException e) {
    e.printStackTrace();
  }
catch (  IllegalAccessException e) {
    e.printStackTrace();
  }
  return (new HtmlCompressor()).compress(html);
}
Program: 109930
Project: 109930
Buggy source:
private static String jsonizeQuestion(Question question) throws SurveyException {
  String options=jsonizeOptions(Arrays.asList(question.getOptListByIndex()));
  String branchMap=jsonizeBranchMap(question.branchMap);
  StringBuilder qtext=new StringBuilder();
  try {
    for (    Component q : question.data) {
      qtext.append(HTML.stringify(q));
    }
  }
 catch (  SurveyException se) {
    LOGGER.info("String_Node_Str" + se);
  }
  return String.format("String_Node_Str",question.quid,CSVLexer.xmlChars2HTML(qtext.toString()),options.equals("String_Node_Str") ? (question.freetext ? String.format("String_Node_Str",getFreetextValue(question)) : "String_Node_Str") : String.format("String_Node_Str",options),branchMap.equals("String_Node_Str") ? "String_Node_Str" : String.format("String_Node_Str",branchMap),question.randomize.equals(CSVParser.defaultValues.get(Survey.RANDOMIZE)) ? "String_Node_Str" : String.format("String_Node_Str",question.randomize),question.ordered.equals(CSVParser.defaultValues.get(Survey.ORDERED)) ? "String_Node_Str" : String.format("String_Node_Str",question.ordered),question.exclusive.equals(CSVParser.defaultValues.get(Survey.EXCLUSIVE)) ? "String_Node_Str" : String.format("String_Node_Str",question.exclusive),question.permitBreakoff == true ? "String_Node_Str" : "String_Node_Str");
}

Fixed version (ground truth):
private static String jsonizeQuestion(Question question) throws SurveyException {
  String options=jsonizeOptions(Arrays.asList(question.getOptListByIndex()));
  String branchMap=jsonizeBranchMap(question.branchMap);
  StringBuilder qtext=new StringBuilder();
  StringBuilder otherStuff=new StringBuilder();
  try {
    for (    Component q : question.data) {
      qtext.append(HTML.stringify(q));
    }
  }
 catch (  SurveyException se) {
    LOGGER.info("String_Node_Str" + se);
  }
  if (options.equals("String_Node_Str"))   otherStuff.append(question.freetext ? String.format("String_Node_Str",getFreetextValue(question)) : "String_Node_Str");
 else   otherStuff.append(String.format("String_Node_Str",options));
  if (!branchMap.equals("String_Node_Str"))   otherStuff.append(String.format("String_Node_Str",branchMap));
  if (question.randomize != CSVParser.defaultValues.get(Survey.RANDOMIZE).booleanValue())   otherStuff.append(String.format("String_Node_Str",question.randomize));
  if (question.ordered != CSVParser.defaultValues.get(Survey.ORDERED).booleanValue())   otherStuff.append(String.format("String_Node_Str",question.ordered));
  if (question.exclusive != CSVParser.defaultValues.get(Survey.EXCLUSIVE).booleanValue())   otherStuff.append(String.format("String_Node_Str",question.exclusive));
  if (!question.permitBreakoff)   otherStuff.append("String_Node_Str");
  return String.format("String_Node_Str",question.quid,CSVLexer.xmlChars2HTML(qtext.toString()),otherStuff.toString());
}
Program: 109931
Project: 109931
Buggy source:
@Override public void refresh(Record record){
  MturkLibrary lib=(MturkLibrary)record.library;
  config.setServiceURL(lib.MTURK_URL);
  service=new RequesterService(config);
}

Fixed version (ground truth):
@Override public void refresh(Record record){
  if (!record.library.getClass().equals(MturkLibrary.class)) {
    record.library=new MturkLibrary();
  }
  MturkLibrary lib=(MturkLibrary)record.library;
  config.setServiceURL(lib.MTURK_URL);
  service=new RequesterService(config);
}
Program: 109932
Project: 109932
Buggy source:
@Override public boolean makeTaskAvailable(String taskId){
  return false;
}

Fixed version (ground truth):
@Override public boolean makeTaskAvailable(String taskId,Record r){
  return false;
}
Program: 109934
Project: 109934
Buggy source:
private int resetQuestionIndices(Block b,int startingIndex){
  int index=startingIndex;
  for (  Question q : b.questions) {
    q.index=index;
    index++;
  }
  for (  Block bb : b.subBlocks) {
    System.out.println(String.format("String_Node_Str",b.strId,bb.strId));
    index+=resetQuestionIndices(bb,index);
  }
  return index;
}

Fixed version (ground truth):
private int resetQuestionIndices(Block b,int startingIndex){
  System.out.println("String_Node_Str" + b.strId + "String_Node_Str"+ startingIndex);
  int index=startingIndex;
  for (  Question q : b.questions) {
    q.index=index;
    index++;
  }
  for (  Block bb : b.subBlocks) {
    System.out.println(String.format("String_Node_Str",b.strId,bb.strId,index));
    index+=resetQuestionIndices(bb,index);
  }
  System.out.println(String.format("String_Node_Str",b.strId,b.blockSize()));
  return b.blockSize();
}