Program: 35337
Project: 35337
Buggy source:
private void handleRequiredElement(final FlexibleElementDTO elementDTO,final IterableGroupPanel tabPanel,final IterableGroupItem tabItem,final ValueResult valueResult,final LayoutConstraintDTO constraintDTO,final Integer iterationId,final LayoutGroupDTO groupLayout){
  elementDTO.addRequiredValueHandler(new RequiredValueHandler(){
    @Override public void onRequiredValueChange(    RequiredValueEvent event){
      final Integer iterationId=tabPanel != null ? tabPanel.getCurrentIterationId() : null;
      currentPhaseRequiredElements.putActual(iterationId,elementDTO.getId(),event.isValueOn());
      if (isCurrentPhase(getCurrentProject().getCurrentPhase())) {
        activePhaseRequiredElements.putActual(iterationId,elementDTO.getId(),event.isValueOn());
      }
      if (event.isImmediate()) {
        if (view.getButtonSavePhase().isEnabled()) {
          view.getButtonSavePhase().fireEvent(Events.OnClick);
        }
 else {
          currentPhaseRequiredElements.saveState();
          if (isActivePhase(getCurrentDisplayedPhase())) {
            activePhaseRequiredElements.saveState();
          }
          refreshActionsToolbar();
        }
      }
      elementDTO.setFilledIn(currentPhaseRequiredElements.isActuallyTrue(elementDTO.getId()));
      view.getGridRequiredElements().getStore().update(elementDTO);
      if (iterationId != null) {
        elementDTO.getTabPanel().setElementValidity(elementDTO,event.isValueOn());
      }
      refreshRequiredElementContentPanelHeader();
    }
  }
);
  if (tabItem != null) {
    tabItem.setElementValidity(elementDTO,elementDTO.isCorrectRequiredValue(valueResult));
    tabItem.refreshTitle();
  }
  elementDTO.setGroup(groupLayout);
  elementDTO.setConstraint(constraintDTO);
  requiredElementsSet.add(elementDTO);
  view.getGridRequiredElements().getStore().removeAll();
  view.getGridRequiredElements().getStore().add(sortRequiredElements(new ArrayList<FlexibleElementDTO>(requiredElementsSet)));
  refreshRequiredElementContentPanelHeader();
  currentPhaseRequiredElements.putSaved(iterationId,elementDTO.getId(),elementDTO.isFilledIn());
  if (isCurrentPhase(getCurrentProject().getCurrentPhase())) {
    activePhaseRequiredElements.putSaved(iterationId,elementDTO.getId(),elementDTO.isFilledIn());
  }
}

Fixed version (ground truth):
private void handleRequiredElement(final FlexibleElementDTO elementDTO,final IterableGroupPanel tabPanel,final IterableGroupItem tabItem,final ValueResult valueResult,final LayoutConstraintDTO constraintDTO,final Integer iterationId,final LayoutGroupDTO groupLayout){
  elementDTO.addRequiredValueHandler(new RequiredValueHandler(){
    @Override public void onRequiredValueChange(    RequiredValueEvent event){
      final Integer iterationId=tabPanel != null ? tabPanel.getCurrentIterationId() : null;
      currentPhaseRequiredElements.putActual(iterationId,elementDTO.getId(),event.isValueOn());
      if (isCurrentPhase(getCurrentProject().getCurrentPhase())) {
        activePhaseRequiredElements.putActual(iterationId,elementDTO.getId(),event.isValueOn());
      }
      if (event.isImmediate()) {
        if (view.getButtonSavePhase().isEnabled()) {
          view.getButtonSavePhase().fireEvent(Events.OnClick);
        }
 else {
          currentPhaseRequiredElements.saveState();
          if (isActivePhase(getCurrentDisplayedPhase())) {
            activePhaseRequiredElements.saveState();
          }
          refreshActionsToolbar();
        }
      }
      elementDTO.setFilledIn(currentPhaseRequiredElements.isActuallyTrue(elementDTO.getId()));
      view.getGridRequiredElements().getStore().update(elementDTO);
      if (iterationId != null) {
        elementDTO.getTabPanel().setElementValidity(elementDTO,event.isValueOn());
      }
      refreshRequiredElementContentPanelHeader();
    }
  }
);
  if (tabItem != null) {
    tabItem.setElementValidity(elementDTO,elementDTO.isCorrectRequiredValue(valueResult));
    tabItem.refreshTitle();
  }
  elementDTO.setGroup(groupLayout);
  elementDTO.setConstraint(constraintDTO);
  if (getCurrentDisplayedPhase().getPhaseModel().getLayout().getGroups().contains(groupLayout)) {
    requiredElementsSet.add(elementDTO);
  }
  view.getGridRequiredElements().getStore().removeAll();
  view.getGridRequiredElements().getStore().add(sortRequiredElements(new ArrayList<FlexibleElementDTO>(requiredElementsSet)));
  refreshRequiredElementContentPanelHeader();
  currentPhaseRequiredElements.putSaved(iterationId,elementDTO.getId(),elementDTO.isFilledIn());
  if (isCurrentPhase(getCurrentProject().getCurrentPhase())) {
    activePhaseRequiredElements.putSaved(iterationId,elementDTO.getId(),elementDTO.isFilledIn());
  }
}