Program: 35477
Project: 35477
Buggy source:
@Override public void refresh(final ContactDTO contactDTO){
  computationTriggerManager.prepareForContact(contactDTO);
  valueChanges.clear();
  view.getDetailsContainer().removeAll();
  final LayoutDTO layout=contactDTO.getContactModel().getDetails().getLayout();
  int count=0;
  for (  final LayoutGroupDTO groupDTO : layout.getGroups()) {
    count+=groupDTO.getConstraints().size();
  }
  if (count == 0) {
    view.fillContainer(new Label(I18N.CONSTANTS.contactDetailsNoDetails()));
    return;
  }
  formPanel=Forms.panel();
  final Grid gridLayout=new Grid(layout.getRowsCount(),layout.getColumnsCount());
  gridLayout.setCellPadding(0);
  gridLayout.setCellSpacing(0);
  final DispatchQueue queue=new DispatchQueue(dispatch,true);
  for (  final LayoutGroupDTO groupLayout : layout.getGroups()) {
    if (!groupLayout.getHasIterations()) {
      FieldSet fieldSet=createGroupLayoutFieldSet(contactDTO,groupLayout,queue,null,null,null);
      gridLayout.setWidget(groupLayout.getRow(),groupLayout.getColumn(),fieldSet);
      continue;
    }
    final FieldSet fieldSet=(FieldSet)groupLayout.getWidget();
    gridLayout.setWidget(groupLayout.getRow(),groupLayout.getColumn(),fieldSet);
    final IterableGroupPanel tabPanel=Forms.iterableGroupPanel(dispatch,groupLayout,contactDTO,ProfileUtils.isGranted(auth(),GlobalPermissionEnum.CREATE_ITERATIONS));
    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);
    GetLayoutGroupIterations getIterations=new GetLayoutGroupIterations(groupLayout.getId(),contactDTO.getId(),-1);
    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(contactDTO,groupLayout,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.getDetailsContainer()));
    fieldSet.layout();
  }
  view.getSaveButton().removeAllListeners();
  view.getSaveButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    final ButtonEvent buttonEvent){
      view.getSaveButton().disable();
      dispatch.execute(buildCheckContactDuplicationCommand(contactDTO),new CommandResultHandler<ListResult<ContactDTO>>(){
        @Override protected void onCommandSuccess(        ListResult<ContactDTO> result){
          if (result == null || result.isEmpty()) {
            updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
              @Override protected void onCommandSuccess(              ContactDTO updatedContactDTO){
                view.getSaveButton().enable();
              }
            }
,view.getDetailsContainer());
            return;
          }
          final DedupeContactDialog dedupeContactDialog=view.generateDedupeDialog();
          dedupeContactDialog.getPossibleDuplicatesGrid().getStore().add(result.getList());
          dedupeContactDialog.getFirstStepMainButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
            @Override public void componentSelected(            ButtonEvent ce){
              updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO result){
                  dedupeContactDialog.hide();
                }
              }
,view.getDetailsContainer());
            }
          }
);
          dedupeContactDialog.setSecondStepHandler(new DedupeContactDialog.SecondStepHandler(){
            @Override public void initialize(            final Integer contactId,            final ListStore<ContactDuplicatedProperty> propertiesStore){
              updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO updatedContactDTO){
                  dispatch.execute(new GetContactDuplicatedProperties(contactId,updatedContactDTO.getId(),null),new CommandResultHandler<ListResult<ContactDuplicatedProperty>>(){
                    @Override protected void onCommandSuccess(                    ListResult<ContactDuplicatedProperty> result){
                      propertiesStore.add(result.getList());
                    }
                  }
,new LoadingMask(dedupeContactDialog));
                }
              }
,dedupeContactDialog);
            }
            @Override public void downloadImage(            String id,            final Image image){
              imageProvider.provideDataUrl(id,new SuccessCallback<String>(){
                @Override public void onSuccess(                String dataUrl){
                  image.setUrl(dataUrl);
                }
              }
);
            }
            @Override public void handleDedupeContact(            final Integer targetedContactId,            List<ContactDuplicatedProperty> selectedProperties){
              dispatch.execute(new DedupeContact(selectedProperties,contactDTO.getId(),targetedContactId),new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO targetedContactDTO){
                  dedupeContactDialog.hide();
                  eventBus.navigateRequest(Page.CONTACT_DASHBOARD.requestWith(RequestParameter.ID,targetedContactId));
                }
              }
);
            }
          }
);
          dedupeContactDialog.addWindowListener(new WindowListener(){
            @Override public void windowHide(            WindowEvent windowEvent){
              super.windowHide(windowEvent);
              if (windowEvent.getType() == Events.Hide) {
                view.getSaveButton().enable();
              }
            }
          }
);
          dedupeContactDialog.show();
        }
      }
);
    }
  }
);
  view.getExportButton().removeAllListeners();
  view.getExportButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    final ButtonEvent ce){
      onExportContact(contactDTO);
    }
  }
);
  queue.start();
  formPanel.add(gridLayout);
  view.fillContainer(formPanel);
}

Fixed version (ground truth):
@Override public void refresh(final ContactDTO contactDTO){
  computationTriggerManager.prepareForContact(contactDTO);
  valueChanges.clear();
  view.getDetailsContainer().removeAll();
  final LayoutDTO layout=contactDTO.getContactModel().getDetails().getLayout();
  int count=0;
  for (  final LayoutGroupDTO groupDTO : layout.getGroups()) {
    count+=groupDTO.getConstraints().size();
  }
  if (count == 0) {
    view.fillContainer(new Label(I18N.CONSTANTS.contactDetailsNoDetails()));
    return;
  }
  formPanel=Forms.panel();
  final Grid gridLayout=new Grid(layout.getRowsCount(),layout.getColumnsCount());
  gridLayout.setCellPadding(0);
  gridLayout.setCellSpacing(0);
  formPanel.add(new Label(I18N.CONSTANTS.contactUniqueId() + contactDTO.getId()));
  final DispatchQueue queue=new DispatchQueue(dispatch,true);
  for (  final LayoutGroupDTO groupLayout : layout.getGroups()) {
    if (!groupLayout.getHasIterations()) {
      FieldSet fieldSet=createGroupLayoutFieldSet(contactDTO,groupLayout,queue,null,null,null);
      fieldSet.setHeadingHtml(groupLayout.getTitle());
      fieldSet.setCollapsible(true);
      fieldSet.setBorders(true);
      gridLayout.setWidget(groupLayout.getRow(),groupLayout.getColumn(),fieldSet);
      continue;
    }
    final FieldSet fieldSet=(FieldSet)groupLayout.getWidget();
    gridLayout.setWidget(groupLayout.getRow(),groupLayout.getColumn(),fieldSet);
    final IterableGroupPanel tabPanel=Forms.iterableGroupPanel(dispatch,groupLayout,contactDTO,ProfileUtils.isGranted(auth(),GlobalPermissionEnum.CREATE_ITERATIONS));
    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);
    GetLayoutGroupIterations getIterations=new GetLayoutGroupIterations(groupLayout.getId(),contactDTO.getId(),-1);
    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(contactDTO,groupLayout,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.getDetailsContainer()));
    fieldSet.layout();
  }
  view.getSaveButton().removeAllListeners();
  view.getSaveButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    final ButtonEvent buttonEvent){
      view.getSaveButton().disable();
      dispatch.execute(buildCheckContactDuplicationCommand(contactDTO),new CommandResultHandler<ListResult<ContactDTO>>(){
        @Override protected void onCommandSuccess(        ListResult<ContactDTO> result){
          if (result == null || result.isEmpty()) {
            updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
              @Override protected void onCommandSuccess(              ContactDTO updatedContactDTO){
                view.getSaveButton().enable();
              }
            }
,view.getDetailsContainer());
            return;
          }
          final DedupeContactDialog dedupeContactDialog=view.generateDedupeDialog();
          dedupeContactDialog.getPossibleDuplicatesGrid().getStore().add(result.getList());
          dedupeContactDialog.getFirstStepMainButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
            @Override public void componentSelected(            ButtonEvent ce){
              updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO result){
                  dedupeContactDialog.hide();
                }
              }
,view.getDetailsContainer());
            }
          }
);
          dedupeContactDialog.setSecondStepHandler(new DedupeContactDialog.SecondStepHandler(){
            @Override public void initialize(            final Integer contactId,            final ListStore<ContactDuplicatedProperty> propertiesStore){
              updateContact(contactDTO,new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO updatedContactDTO){
                  dispatch.execute(new GetContactDuplicatedProperties(contactId,updatedContactDTO.getId(),null),new CommandResultHandler<ListResult<ContactDuplicatedProperty>>(){
                    @Override protected void onCommandSuccess(                    ListResult<ContactDuplicatedProperty> result){
                      propertiesStore.add(result.getList());
                    }
                  }
,new LoadingMask(dedupeContactDialog));
                }
              }
,dedupeContactDialog);
            }
            @Override public void downloadImage(            String id,            final Image image){
              imageProvider.provideDataUrl(id,new SuccessCallback<String>(){
                @Override public void onSuccess(                String dataUrl){
                  image.setUrl(dataUrl);
                }
              }
);
            }
            @Override public void handleDedupeContact(            final Integer targetedContactId,            List<ContactDuplicatedProperty> selectedProperties){
              dispatch.execute(new DedupeContact(selectedProperties,contactDTO.getId(),targetedContactId),new CommandResultHandler<ContactDTO>(){
                @Override protected void onCommandSuccess(                ContactDTO targetedContactDTO){
                  dedupeContactDialog.hide();
                  eventBus.navigateRequest(Page.CONTACT_DASHBOARD.requestWith(RequestParameter.ID,targetedContactId));
                }
              }
);
            }
          }
);
          dedupeContactDialog.addWindowListener(new WindowListener(){
            @Override public void windowHide(            WindowEvent windowEvent){
              super.windowHide(windowEvent);
              if (windowEvent.getType() == Events.Hide) {
                view.getSaveButton().enable();
              }
            }
          }
);
          dedupeContactDialog.show();
        }
      }
);
    }
  }
);
  view.getExportButton().removeAllListeners();
  view.getExportButton().addSelectionListener(new SelectionListener<ButtonEvent>(){
    @Override public void componentSelected(    final ButtonEvent ce){
      onExportContact(contactDTO);
    }
  }
);
  queue.start();
  formPanel.add(gridLayout);
  view.fillContainer(formPanel);
}