Program: 178896
Project: 178896
Buggy source:
public void handleCoreEvent(CoreEvent event){
  final PageEditorInput input=(PageEditorInput)getEditorInput();
  XWikiEclipsePage page=input.getPage();
  String targetPageId=null;
  DataManager dataManager=null;
  if (event.getSource() instanceof DataManager) {
    dataManager=(DataManager)event.getSource();
  }
  boolean updatePage=false;
switch (event.getType()) {
case OBJECT_STORED:
    XWikiEclipseObject object=(XWikiEclipseObject)event.getData();
  targetPageId=object.getPageId();
updatePage=page.getDataManager().equals(dataManager) && page.getId().equals(targetPageId);
break;
case OBJECT_REMOVED:
updatePage=page.getDataManager().equals(dataManager) && page.getId().equals(targetPageId);
break;
case DATA_MANAGER_CONNECTED:
updatePage=page.getDataManager().equals(dataManager);
Display.getDefault().syncExec(new Runnable(){
public void run(){
PageEditor.this.updateInfo();
}
}
);
break;
case REFRESH:
Object data=event.getData();
if (data instanceof DataManager || data instanceof XWikiEclipsePageSummary || data instanceof XWikiEclipseSpaceSummary) {
if (data instanceof XWikiEclipsePageSummary) {
return;
}
 else if (data instanceof DataManager) {
DataManager aDataManager=(DataManager)data;
if (!aDataManager.equals(page.getDataManager())) return;
}
 else if (data instanceof XWikiEclipseSpaceSummary) {
XWikiEclipseSpaceSummary space=(XWikiEclipseSpaceSummary)data;
if (!space.getDataManager().equals(page.getDataManager()) || !space.getId().equals(page.getSpace())) return;
}
if (isDirty()) {
MessageBox messageBox=new MessageBox(Display.getCurrent().getShells()[0],SWT.YES | SWT.NO | SWT.CANCEL| SWT.ICON_QUESTION);
messageBox.setMessage(String.format("String_Node_Str",page.getId()));
messageBox.setText("String_Node_Str");
this.setFocus();
int result=messageBox.open();
if (result == SWT.YES) {
this.doSave(null);
return;
}
 else if (result == SWT.CANCEL) {
return;
}
}
doRevertToSaved();
updatePage=true;
}
break;
case PAGE_REMOVED:
XWikiEclipsePage aPage=(XWikiEclipsePage)event.getData();
if (aPage.getXWikiEclipseId().equals(page.getXWikiEclipseId())) {
this.close(false);
}
break;
case SPACE_REMOVED:
XWikiEclipseSpaceSummary aSpace=(XWikiEclipseSpaceSummary)event.getData();
if (aSpace.getDataManager().equals(page.getDataManager()) && aSpace.getId().equals(page.getSpace())) {
this.close(false);
}
break;
case DATA_MANAGER_UNREGISTERED:
DataManager aDataManager=(DataManager)event.getData();
if (aDataManager.equals(page.getDataManager())) {
this.close(false);
}
break;
}
if (updatePage) {
if (!isDirty()) {
}
}
}

Fixed version (ground truth):
public void handleCoreEvent(CoreEvent event){
  final PageEditorInput input=(PageEditorInput)getEditorInput();
  XWikiEclipsePage page=input.getPage();
  String targetPageId=null;
  DataManager dataManager=null;
  if (event.getSource() instanceof DataManager) {
    dataManager=(DataManager)event.getSource();
  }
  boolean updatePage=false;
switch (event.getType()) {
case OBJECT_STORED:
    XWikiEclipseObject object=(XWikiEclipseObject)event.getData();
  targetPageId=object.getPageId();
updatePage=page.getDataManager().equals(dataManager) && page.getId().equals(targetPageId);
break;
case OBJECT_REMOVED:
updatePage=page.getDataManager().equals(dataManager) && page.getId().equals(targetPageId);
break;
case DATA_MANAGER_CONNECTED:
updatePage=page.getDataManager().equals(dataManager);
Display.getDefault().syncExec(new Runnable(){
public void run(){
PageEditor.this.updateInfo();
}
}
);
break;
case REFRESH:
Object data=event.getData();
if (data instanceof DataManager || data instanceof XWikiEclipsePageSummary || data instanceof XWikiEclipseSpaceSummary) {
if (data instanceof XWikiEclipsePageSummary) {
return;
}
 else if (data instanceof DataManager) {
DataManager aDataManager=(DataManager)data;
if (!aDataManager.equals(page.getDataManager())) return;
}
 else if (data instanceof XWikiEclipseSpaceSummary) {
XWikiEclipseSpaceSummary space=(XWikiEclipseSpaceSummary)data;
if (!space.getDataManager().equals(page.getDataManager()) || !space.getId().equals(page.getSpace())) return;
}
if (isDirty()) {
MessageBox messageBox=new MessageBox(Display.getCurrent().getShells()[0],SWT.YES | SWT.NO | SWT.CANCEL| SWT.ICON_QUESTION);
messageBox.setMessage(String.format("String_Node_Str",page.getId()));
messageBox.setText("String_Node_Str");
this.setFocus();
int result=messageBox.open();
if (result == SWT.YES) {
this.doSave(null);
return;
}
 else if (result == SWT.CANCEL) {
return;
}
try {
page.getDataManager().clearPageStatus(StorageUtils.getExtendedPageId(page.getId(),page.getLanguage()));
}
 catch (Exception ex) {
}
}
doRevertToSaved();
updatePage=true;
}
break;
case PAGE_REMOVED:
XWikiEclipsePage aPage=(XWikiEclipsePage)event.getData();
if (aPage.getXWikiEclipseId().equals(page.getXWikiEclipseId())) {
this.close(false);
}
break;
case SPACE_REMOVED:
XWikiEclipseSpaceSummary aSpace=(XWikiEclipseSpaceSummary)event.getData();
if (aSpace.getDataManager().equals(page.getDataManager()) && aSpace.getId().equals(page.getSpace())) {
this.close(false);
}
break;
case DATA_MANAGER_UNREGISTERED:
DataManager aDataManager=(DataManager)event.getData();
if (aDataManager.equals(page.getDataManager())) {
this.close(false);
}
break;
}
try {
if (updatePage) {
if (!isDirty()) {
final XWikiEclipsePage newPage=page.getDataManager().getPage(page.getWiki(),page.getSpace(),page.getName(),page.getLanguage());
if (page.getMajorVersion() != newPage.getMajorVersion()) {
final ISourceViewer sourceViewer=getSourceViewer();
if (sourceViewer != null) {
Display.getDefault().syncExec(new Runnable(){
public void run(){
int caretOffset=sourceViewer.getTextWidget().getCaretOffset();
int topPixel=sourceViewer.getTextWidget().getTopPixel();
try {
doSetInput(new PageEditorInput(newPage,input.isReadOnly()));
}
 catch (CoreException e) {
CoreLog.logError("String_Node_Str",e);
}
sourceViewer.getTextWidget().setCaretOffset(caretOffset);
sourceViewer.getTextWidget().setTopPixel(topPixel);
updateInfo();
doSave(new NullProgressMonitor());
}
}
);
}
}
}
}
}
 catch (XWikiEclipseStorageException e) {
CoreLog.logError("String_Node_Str",e);
}
}