Program: 101228
Project: 101228
Buggy source:
/** 
 * Add Widget to Left Container
 * @param event
 * @throws Exception
 */
private void addApplicationToContainer(Event<UIAddNewApplication> event) throws Exception {
  if (UIAddNewApplication.UI_COMPONENT_PARENT == null)   return;
  UIContainer uiWidgetContainer=(UIContainer)UIAddNewApplication.UI_COMPONENT_PARENT;
  String applicationId=event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
  StringBuilder windowId=new StringBuilder(PortalConfig.USER_TYPE);
  windowId.append("String_Node_Str").append(event.getRequestContext().getRemoteUser());
  windowId.append("String_Node_Str").append(applicationId).append('/');
  ApplicationRegistryService service=uiWidgetContainer.getApplicationComponent(ApplicationRegistryService.class);
  Application application=service.getApplication(applicationId);
  if (application == null)   return;
  UIWidget uiWidget=uiWidgetContainer.createUIComponent(event.getRequestContext(),UIWidget.class,null,null);
  windowId.append(uiWidget.hashCode());
  uiWidget.setApplicationInstanceId(windowId.toString());
  uiWidget.setApplicationName(application.getApplicationName());
  uiWidget.setApplicationGroup(application.getApplicationGroup());
  uiWidget.setApplicationOwnerType(application.getApplicationType());
  uiWidgetContainer.addChild(uiWidget);
  UIWidgets uiWidgets=uiWidgetContainer.getAncestorOfType(UIWidgets.class);
  Widgets widgets=PortalDataMapper.toWidgets(uiWidgets);
  UserPortalConfigService configService=uiWidgetContainer.getApplicationComponent(UserPortalConfigService.class);
  configService.update(widgets);
  UIPortalApplication uiPortalApp=(UIPortalApplication)event.getRequestContext().getUIApplication();
  uiPortalApp.getUserPortalConfig().setWidgets(widgets);
  UIWelcomeComponent uiWelcomeComponent=uiWidgetContainer.getAncestorOfType(UIWelcomeComponent.class);
  event.getRequestContext().addUIComponentToUpdateByAjax(uiWelcomeComponent);
}

Fixed version (ground truth):
/** 
 * Add Widget to Left Container
 * @param event
 * @throws Exception
 */
private void addApplicationToContainer(Event<UIAddNewApplication> event) throws Exception {
  UIContainer uiWidgetContainer=(UIContainer)event.getSource().getUiComponentParent();
  String applicationId=event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
  StringBuilder windowId=new StringBuilder(PortalConfig.USER_TYPE);
  windowId.append("String_Node_Str").append(event.getRequestContext().getRemoteUser());
  windowId.append("String_Node_Str").append(applicationId).append('/');
  ApplicationRegistryService service=uiWidgetContainer.getApplicationComponent(ApplicationRegistryService.class);
  Application application=service.getApplication(applicationId);
  if (application == null)   return;
  UIWidget uiWidget=uiWidgetContainer.createUIComponent(event.getRequestContext(),UIWidget.class,null,null);
  windowId.append(uiWidget.hashCode());
  uiWidget.setApplicationInstanceId(windowId.toString());
  uiWidget.setApplicationName(application.getApplicationName());
  uiWidget.setApplicationGroup(application.getApplicationGroup());
  uiWidget.setApplicationOwnerType(application.getApplicationType());
  uiWidgetContainer.addChild(uiWidget);
  UIWidgets uiWidgets=uiWidgetContainer.getAncestorOfType(UIWidgets.class);
  Widgets widgets=PortalDataMapper.toWidgets(uiWidgets);
  UserPortalConfigService configService=uiWidgetContainer.getApplicationComponent(UserPortalConfigService.class);
  configService.update(widgets);
  UIPortalApplication uiPortalApp=(UIPortalApplication)event.getRequestContext().getUIApplication();
  uiPortalApp.getUserPortalConfig().setWidgets(widgets);
  UIWelcomeComponent uiWelcomeComponent=uiWidgetContainer.getAncestorOfType(UIWelcomeComponent.class);
  event.getRequestContext().addUIComponentToUpdateByAjax(uiWelcomeComponent);
}