Program: 67992
Project: 67992
Buggy source:
protected void okPressed(){
  Object firstElement=designElement;
  if (firstElement instanceof StructuredSelection) {
    firstElement=((StructuredSelection)firstElement).getFirstElement();
  }
  String path=getPath();
  LibraryHandle libraryHandle=null;
  try {
    ModuleHandle handle=openOrCreateLibrary(SessionHandleAdapter.getInstance().getSessionHandle(),path);
    libraryHandle=(LibraryHandle)handle;
    if (firstElement instanceof StyleHandle && libraryHandle.getVisibleThemes(IAccessControl.DIRECTLY_INCLUDED_LEVEL).size() > 0) {
      Object[] result=getExportTheme((StyleHandle)firstElement,libraryHandle);
      if (result == null)       return;
 else       if (result[0] == null) {
        cancelPressed();
        return;
      }
 else {
        boolean notExist=((Boolean)result[1]).booleanValue();
        if (!notExist) {
          int confirm=confirmOverride();
switch (confirm) {
case 0:
            break;
case 1:
          return;
case 2:
default :
        cancelPressed();
      return;
  }
}
ElementExportUtil.exportStyle((StyleHandle)firstElement,(ThemeHandle)result[0],true);
}
}
 else if (firstElement instanceof DesignElementHandle) {
boolean notExist=ElementExportUtil.canExport((DesignElementHandle)firstElement,libraryHandle,false);
if (!notExist) {
int confirm=confirmOverride();
switch (confirm) {
case 0:
  break;
case 1:
return;
case 2:
default :
cancelPressed();
return;
}
}
if (firstElement instanceof ImageHandle && DesignChoiceConstants.IMAGE_REF_TYPE_EMBED.equals(((ImageHandle)firstElement).getSource())) {
exportEmbeddedImage((ImageHandle)firstElement,libraryHandle);
}
 else {
ElementExportUtil.exportElement((DesignElementHandle)firstElement,libraryHandle,true);
}
}
 else if (firstElement instanceof StructureHandle) {
boolean notExist=ElementExportUtil.canExport((StructureHandle)firstElement,libraryHandle,false);
if (!notExist) {
int confirm=confirmOverride();
switch (confirm) {
case 0:
break;
case 1:
return;
case 2:
default :
cancelPressed();
return;
}
}
ElementExportUtil.exportStructure((StructureHandle)firstElement,libraryHandle,true);
}
}
 catch (DesignFileException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
}
catch (SemanticException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
}
 finally {
if (libraryHandle != null) {
try {
libraryHandle.save();
}
 catch (IOException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
}
libraryHandle.close();
}
}
IReportResourceSynchronizer synchronizer=ReportPlugin.getDefault().getResourceSynchronizerService();
if (synchronizer != null) {
synchronizer.notifyResourceChanged(new LibrarySaveChangeEvent(this,Path.fromOSString(path),IReportResourceChangeEvent.LibraySaveChange,Path.fromOSString(path).toOSString()));
}
super.okPressed();
}

Fixed version (ground truth):
protected void okPressed(){
  Object firstElement=designElement;
  if (firstElement instanceof StructuredSelection) {
    firstElement=((StructuredSelection)firstElement).getFirstElement();
  }
  String path=getPath();
  LibraryHandle libraryHandle=null;
  boolean isDone=true;
  try {
    ModuleHandle handle=openOrCreateLibrary(SessionHandleAdapter.getInstance().getSessionHandle(),path);
    libraryHandle=(LibraryHandle)handle;
    if (firstElement instanceof StyleHandle && libraryHandle.getVisibleThemes(IAccessControl.DIRECTLY_INCLUDED_LEVEL).size() > 0) {
      Object[] result=getExportTheme((StyleHandle)firstElement,libraryHandle);
      if (result == null)       return;
 else       if (result[0] == null) {
        cancelPressed();
        return;
      }
 else {
        boolean notExist=((Boolean)result[1]).booleanValue();
        if (!notExist) {
          int confirm=confirmOverride();
switch (confirm) {
case 0:
            break;
case 1:
          return;
case 2:
default :
        cancelPressed();
      return;
  }
}
ElementExportUtil.exportStyle((StyleHandle)firstElement,(ThemeHandle)result[0],true);
}
}
 else if (firstElement instanceof DesignElementHandle) {
boolean notExist=ElementExportUtil.canExport((DesignElementHandle)firstElement,libraryHandle,false);
if (!notExist) {
int confirm=confirmOverride();
switch (confirm) {
case 0:
  break;
case 1:
return;
case 2:
default :
cancelPressed();
return;
}
}
if (firstElement instanceof ImageHandle && DesignChoiceConstants.IMAGE_REF_TYPE_EMBED.equals(((ImageHandle)firstElement).getSource())) {
isDone=exportEmbeddedImage((ImageHandle)firstElement,libraryHandle);
}
 else {
ElementExportUtil.exportElement((DesignElementHandle)firstElement,libraryHandle,true);
}
}
 else if (firstElement instanceof StructureHandle) {
boolean notExist=ElementExportUtil.canExport((StructureHandle)firstElement,libraryHandle,false);
if (!notExist) {
int confirm=confirmOverride();
switch (confirm) {
case 0:
break;
case 1:
return;
case 2:
default :
cancelPressed();
return;
}
}
ElementExportUtil.exportStructure((StructureHandle)firstElement,libraryHandle,true);
}
}
 catch (DesignFileException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
isDone=false;
}
catch (SemanticException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
isDone=false;
}
 finally {
if (libraryHandle != null) {
try {
libraryHandle.save();
}
 catch (IOException e) {
ExceptionHandler.handle(e);
e.printStackTrace();
}
libraryHandle.close();
}
}
IReportResourceSynchronizer synchronizer=ReportPlugin.getDefault().getResourceSynchronizerService();
if (synchronizer != null && isDone) {
synchronizer.notifyResourceChanged(new LibrarySaveChangeEvent(this,Path.fromOSString(path),IReportResourceChangeEvent.LibraySaveChange,Path.fromOSString(path).toOSString()));
}
super.okPressed();
}