Program: 146696
Project: 146696
Buggy source:
public void next(){
  String next=session.getNeededData();
  if (next == null) {
    String xmlns=session.getForm();
    if (xmlns == null) {
      this.back();
      return;
    }
    Entry entry=session.getCurrentEntry();
    if (failedAssertion(entry.getAssertions())) {
      return;
    }
    String title;
    if (CommCareSense.sense()) {
      title=null;
    }
 else {
      title=Localizer.clearArguments(entry.getText().evaluate());
    }
    initializer=null;
    suiteTable.clear();
    entryTable.clear();
    menuTable.clear();
    final Vector<StackOperation> ops=entry.getPostEntrySessionOperations();
    CommCareFormEntryState state=new CommCareFormEntryState(title,xmlns,getPreloaders(),CommCareContext._().getFuncHandlers(),getIif()){
      protected void goHome(){
        session.markCurrentFrameForDeath();
        if (ops.size() > 0) {
          EvaluationContext ec=session.getEvaluationContext(getIif());
          session.executeStackOperations(ops,ec);
        }
        if (session.finishAndPop()) {
          next();
        }
 else {
          J2MEDisplay.startStateWithLoadingScreen(new CommCareHomeState());
        }
      }
      public void abort(){
        back();
      }
    }
;
    J2MEDisplay.startStateWithLoadingScreen(state);
    return;
  }
  if (next.equals(SessionFrame.STATE_COMMAND_ID)) {
    if (session.getCommand() == null) {
      session.clearAllState();
      J2MEDisplay.startStateWithLoadingScreen(new CommCareHomeState());
      return;
    }
    MenuHomeState state=new MenuHomeState(this,session.getMenu(session.getCommand())){
      public void entry(      Suite suite,      Entry entry){
        throw new RuntimeException("String_Node_Str");
      }
      public void exitMenuTransition(){
        CommCareSessionController.this.back();
      }
    }
;
    J2MEDisplay.startStateWithLoadingScreen(state);
    return;
  }
  Suite suite=session.getCurrentSuite();
  SessionDatum datum=session.getNeededDatum();
  EvaluationContext context=session.getEvaluationContext(getIif());
  if (datum.getNodeset() == null) {
    XPathExpression form;
    try {
      form=XPathParseTool.parseXPath(datum.getValue());
    }
 catch (    XPathSyntaxException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());
    }
    if (datum.getType() == SessionDatum.DATUM_TYPE_FORM) {
      CommCareSessionController.this.session.setXmlns(XPathFuncExpr.toString(form.eval(context.getMainInstance(),context)));
      CommCareSessionController.this.session.setDatum("String_Node_Str","String_Node_Str");
    }
 else {
      CommCareSessionController.this.session.setDatum(datum.getDataId(),XPathFuncExpr.toString(form.eval(context.getMainInstance(),context)));
    }
    next();
    return;
  }
  Detail shortDetail=suite.getDetail(datum.getShortDetail());
  Detail longDetail=null;
  if (datum.getLongDetail() != null) {
    longDetail=suite.getDetail(datum.getLongDetail());
  }
  final NodeEntitySet nes=new NodeEntitySet(datum.getNodeset(),context);
  Entity<TreeReference> entity=new CommCareEntity(shortDetail,longDetail,context,nes);
  final CommCareSelectState<TreeReference> select=new CommCareSelectState<TreeReference>(entity,nes){
    SessionDatum datum;
    EvaluationContext context;
{
      datum=session.getNeededDatum();
      context=session.getEvaluationContext(getIif());
    }
    public void cancel(){
      CommCareSessionController.this.back();
    }
    public void entitySelected(    int id){
      TreeReference selected=nes.get(id);
      TreeReference outcome=XPathReference.getPathExpr(datum.getValue()).getReference().contextualize(selected);
      AbstractTreeElement element=context.resolveReference(outcome);
      if (element == null) {
        throw new RuntimeException("String_Node_Str" + outcome.toString());
      }
      String outputData=element.getValue().uncast().getString();
      CommCareSessionController.this.session.setDatum(datum.getDataId(),outputData);
      CommCareSessionController.this.next();
    }
  }
;
  J2MEDisplay.startStateWithLoadingScreen(select,new ProgressIndicator(){
    public double getProgress(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getProgress();
      }
 else {
        return nes.getProgress();
      }
    }
    public String getCurrentLoadingStatus(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getCurrentLoadingStatus();
      }
 else {
        return nes.getCurrentLoadingStatus();
      }
    }
    public int getIndicatorsProvided(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getIndicatorsProvided();
      }
 else {
        return nes.getIndicatorsProvided();
      }
    }
  }
);
  return;
}

Fixed version (ground truth):
public void next(){
  String next=session.getNeededData();
  if (next == null) {
    String xmlns=session.getForm();
    if (xmlns == null) {
      this.back();
      return;
    }
    Entry entry=session.getCurrentEntry();
    if (failedAssertion(entry.getAssertions())) {
      return;
    }
    String title;
    if (CommCareSense.sense()) {
      title=null;
    }
 else {
      title=Localizer.clearArguments(entry.getText().evaluate());
    }
    initializer=null;
    suiteTable.clear();
    entryTable.clear();
    menuTable.clear();
    final Vector<StackOperation> ops=entry.getPostEntrySessionOperations();
    CommCareFormEntryState state=new CommCareFormEntryState(title,xmlns,getPreloaders(),CommCareContext._().getFuncHandlers(),getIif()){
      protected void goHome(){
        if (session.finishExecuteAndPop(session.getEvaluationContext(getIif()))) {
          next();
        }
 else {
          J2MEDisplay.startStateWithLoadingScreen(new CommCareHomeState());
        }
      }
      public void abort(){
        back();
      }
    }
;
    J2MEDisplay.startStateWithLoadingScreen(state);
    return;
  }
  if (next.equals(SessionFrame.STATE_COMMAND_ID)) {
    if (session.getCommand() == null) {
      session.clearAllState();
      J2MEDisplay.startStateWithLoadingScreen(new CommCareHomeState());
      return;
    }
    MenuHomeState state=new MenuHomeState(this,session.getMenu(session.getCommand())){
      public void entry(      Suite suite,      Entry entry){
        throw new RuntimeException("String_Node_Str");
      }
      public void exitMenuTransition(){
        CommCareSessionController.this.back();
      }
    }
;
    J2MEDisplay.startStateWithLoadingScreen(state);
    return;
  }
  Suite suite=session.getCurrentSuite();
  SessionDatum datum=session.getNeededDatum();
  EvaluationContext context=session.getEvaluationContext(getIif());
  if (datum.getNodeset() == null) {
    XPathExpression form;
    try {
      form=XPathParseTool.parseXPath(datum.getValue());
    }
 catch (    XPathSyntaxException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());
    }
    if (datum.getType() == SessionDatum.DATUM_TYPE_FORM) {
      CommCareSessionController.this.session.setXmlns(XPathFuncExpr.toString(form.eval(context.getMainInstance(),context)));
      CommCareSessionController.this.session.setDatum("String_Node_Str","String_Node_Str");
    }
 else {
      CommCareSessionController.this.session.setDatum(datum.getDataId(),XPathFuncExpr.toString(form.eval(context.getMainInstance(),context)));
    }
    next();
    return;
  }
  Detail shortDetail=suite.getDetail(datum.getShortDetail());
  Detail longDetail=null;
  if (datum.getLongDetail() != null) {
    longDetail=suite.getDetail(datum.getLongDetail());
  }
  final NodeEntitySet nes=new NodeEntitySet(datum.getNodeset(),context);
  Entity<TreeReference> entity=new CommCareEntity(shortDetail,longDetail,context,nes);
  final CommCareSelectState<TreeReference> select=new CommCareSelectState<TreeReference>(entity,nes){
    SessionDatum datum;
    EvaluationContext context;
{
      datum=session.getNeededDatum();
      context=session.getEvaluationContext(getIif());
    }
    public void cancel(){
      CommCareSessionController.this.back();
    }
    public void entitySelected(    int id){
      TreeReference selected=nes.get(id);
      TreeReference outcome=XPathReference.getPathExpr(datum.getValue()).getReference().contextualize(selected);
      AbstractTreeElement element=context.resolveReference(outcome);
      if (element == null) {
        throw new RuntimeException("String_Node_Str" + outcome.toString());
      }
      String outputData=element.getValue().uncast().getString();
      CommCareSessionController.this.session.setDatum(datum.getDataId(),outputData);
      CommCareSessionController.this.next();
    }
  }
;
  J2MEDisplay.startStateWithLoadingScreen(select,new ProgressIndicator(){
    public double getProgress(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getProgress();
      }
 else {
        return nes.getProgress();
      }
    }
    public String getCurrentLoadingStatus(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getCurrentLoadingStatus();
      }
 else {
        return nes.getCurrentLoadingStatus();
      }
    }
    public int getIndicatorsProvided(){
      if (nes.loaded()) {
        return select.getProgressIndicator().getIndicatorsProvided();
      }
 else {
        return nes.getIndicatorsProvided();
      }
    }
  }
);
  return;
}