Program: 35407
Project: 35407
Buggy source:
/** 
 * Loads a project phase into the selected tab panel.
 * @param phaseDTO The phase to display.
 */
private void loadPhaseOnTab(final PhaseDTO phaseDTO){
  final boolean phaseIsEnded=isEndedPhase(phaseDTO);
  setCurrentDisplayedPhase(phaseDTO);
  currentPhaseRequiredElements.clear();
  valueChanges.clear();
  for (  final TabItem tab : view.getTabPanelPhases().getItems()) {
    tab.removeAll();
  }
  view.getPanelSelectedPhase().removeAll();
  view.getGridRequiredElements().getStore().removeAll();
  view.getTabPanelPhases().getSelectedItem().add(view.getPanelProjectModel());
  requiredElementsSet.clear();
  final Grid layoutGrid=(Grid)phaseDTO.getPhaseModel().getWidget();
  layoutGrid.setStyleName("String_Node_Str");
  view.getPanelSelectedPhase().add(layoutGrid);
  final DispatchQueue queue=new DispatchQueue(dispatch,true){
    @Override protected void onComplete(){
      injector.getProjectDashboardPresenter().getView().layoutView();
      view.layout();
      Profiler.INSTANCE.endScenario(Scenario.OPEN_PROJECT);
    }
  }
;
  final ProjectDTO project=getCurrentProject();
  computationTriggerManager.prepareForProject(project);
  for (  final LayoutGroupDTO groupDTO : phaseDTO.getPhaseModel().getLayout().getGroups()) {
    if (!groupDTO.getHasIterations()) {
      FieldSet fieldSet=createGroupLayoutFieldSet(getCurrentProject(),groupDTO,queue,null,null,null);
      fieldSet.setHeadingHtml(groupDTO.getTitle());
      fieldSet.setCollapsible(true);
      fieldSet.setBorders(true);
      layoutGrid.setWidget(groupDTO.getRow(),groupDTO.getColumn(),fieldSet);
      continue;
    }
    final FieldSet fieldSet=(FieldSet)groupDTO.getWidget();
    layoutGrid.setWidget(groupDTO.getRow(),groupDTO.getColumn(),fieldSet);
    final IterableGroupPanel tabPanel=Forms.iterableGroupPanel(dispatch,groupDTO,getCurrentProject(),ProfileUtils.isGranted(auth(),GlobalPermissionEnum.CREATE_ITERATIONS) && getCurrentProject().getCurrentAmendment() == null);
    tabPanel.setDelegate(this);
    fieldSet.add(tabPanel);
    tabPanel.setAutoHeight(true);
    tabPanel.setAutoWidth(true);
    tabPanel.setTabScroll(true);
    tabPanel.addStyleName("String_Node_Str");
    tabPanel.setBorders(true);
    tabPanel.setBodyBorder(false);
    Integer amendmentId;
    if (getCurrentProject().getCurrentAmendment() != null) {
      amendmentId=getCurrentProject().getCurrentAmendment().getId();
    }
 else {
      amendmentId=-1;
    }
    GetLayoutGroupIterations getIterations=new GetLayoutGroupIterations(groupDTO.getId(),getCurrentProject().getId(),amendmentId);
    queue.add(getIterations,new CommandResultHandler<ListResult<LayoutGroupIterationDTO>>(){
      @Override public void onCommandFailure(      final Throwable throwable){
        if (Log.isErrorEnabled()) {
          Log.error("String_Node_Str",throwable);
        }
        throw new RuntimeException(throwable);
      }
      @Override protected void onCommandSuccess(      ListResult<LayoutGroupIterationDTO> result){
        DispatchQueue iterationsQueue=new DispatchQueue(dispatch,true);
        for (        final LayoutGroupIterationDTO iteration : result.getList()) {
          final IterableGroupItem tab=new IterableGroupItem(tabPanel,iteration.getId(),iteration.getName());
          tabPanel.addIterationTab(tab);
          Layout tabLayout=Layouts.fitLayout();
          tab.setLayout(tabLayout);
          FieldSet tabSet=createGroupLayoutFieldSet(getCurrentProject(),groupDTO,iterationsQueue,iteration == null ? null : iteration.getId(),tabPanel,tab);
          tab.add(tabSet);
        }
        iterationsQueue.start();
        if (tabPanel.getItemCount() > 0) {
          tabPanel.setSelection(tabPanel.getItem(0));
        }
      }
    }
,new LoadingMask(view.getTabPanelPhases()));
    fieldSet.layout();
  }
  queue.start();
}

Fixed version (ground truth):
/** 
 * Loads a project phase into the selected tab panel.
 * @param phaseDTO The phase to display.
 */
private void loadPhaseOnTab(final PhaseDTO phaseDTO){
  initCurrentPhaseCounter();
  final boolean phaseIsEnded=isEndedPhase(phaseDTO);
  setCurrentDisplayedPhase(phaseDTO);
  currentPhaseRequiredElements.clear();
  valueChanges.clear();
  for (  final TabItem tab : view.getTabPanelPhases().getItems()) {
    tab.removeAll();
  }
  view.getPanelSelectedPhase().removeAll();
  view.getGridRequiredElements().getStore().removeAll();
  view.getTabPanelPhases().getSelectedItem().add(view.getPanelProjectModel());
  requiredElementsSet.clear();
  final Grid layoutGrid=(Grid)phaseDTO.getPhaseModel().getWidget();
  layoutGrid.setStyleName("String_Node_Str");
  view.getPanelSelectedPhase().add(layoutGrid);
  final DispatchQueue queue=new DispatchQueue(dispatch,true){
    @Override protected void onComplete(){
      injector.getProjectDashboardPresenter().getView().layoutView();
      view.layout();
      Profiler.INSTANCE.endScenario(Scenario.OPEN_PROJECT);
    }
  }
;
  final ProjectDTO project=getCurrentProject();
  computationTriggerManager.prepareForProject(project);
  for (  final LayoutGroupDTO groupDTO : phaseDTO.getPhaseModel().getLayout().getGroups()) {
    if (!groupDTO.getHasIterations()) {
      FieldSet fieldSet=createGroupLayoutFieldSet(getCurrentProject(),groupDTO,queue,null,null,null);
      fieldSet.setHeadingHtml(groupDTO.getTitle());
      fieldSet.setCollapsible(true);
      fieldSet.setBorders(true);
      layoutGrid.setWidget(groupDTO.getRow(),groupDTO.getColumn(),fieldSet);
      continue;
    }
    final FieldSet fieldSet=(FieldSet)groupDTO.getWidget();
    layoutGrid.setWidget(groupDTO.getRow(),groupDTO.getColumn(),fieldSet);
    final IterableGroupPanel tabPanel=Forms.iterableGroupPanel(dispatch,groupDTO,getCurrentProject(),ProfileUtils.isGranted(auth(),GlobalPermissionEnum.CREATE_ITERATIONS) && getCurrentProject().getCurrentAmendment() == null);
    tabPanel.setDelegate(this);
    fieldSet.add(tabPanel);
    tabPanel.setAutoHeight(true);
    tabPanel.setAutoWidth(true);
    tabPanel.setTabScroll(true);
    tabPanel.addStyleName("String_Node_Str");
    tabPanel.setBorders(true);
    tabPanel.setBodyBorder(false);
    Integer amendmentId;
    if (getCurrentProject().getCurrentAmendment() != null) {
      amendmentId=getCurrentProject().getCurrentAmendment().getId();
    }
 else {
      amendmentId=-1;
    }
    GetLayoutGroupIterations getIterations=new GetLayoutGroupIterations(groupDTO.getId(),getCurrentProject().getId(),amendmentId);
    queue.add(getIterations,new CommandResultHandler<ListResult<LayoutGroupIterationDTO>>(){
      @Override public void onCommandFailure(      final Throwable throwable){
        if (Log.isErrorEnabled()) {
          Log.error("String_Node_Str",throwable);
        }
        throw new RuntimeException(throwable);
      }
      @Override protected void onCommandSuccess(      ListResult<LayoutGroupIterationDTO> result){
        DispatchQueue iterationsQueue=new DispatchQueue(dispatch,true);
        for (        final LayoutGroupIterationDTO iteration : result.getList()) {
          final IterableGroupItem tab=new IterableGroupItem(tabPanel,iteration.getId(),iteration.getName());
          tabPanel.addIterationTab(tab);
          Layout tabLayout=Layouts.fitLayout();
          tab.setLayout(tabLayout);
          FieldSet tabSet=createGroupLayoutFieldSet(getCurrentProject(),groupDTO,iterationsQueue,iteration == null ? null : iteration.getId(),tabPanel,tab);
          tab.add(tabSet);
        }
        iterationsQueue.start();
        if (tabPanel.getItemCount() > 0) {
          tabPanel.setSelection(tabPanel.getItem(0));
        }
      }
    }
,new LoadingMask(view.getTabPanelPhases()));
    fieldSet.layout();
  }
  queue.start();
}