Bug 562233 - Insulating SWT from exceptions in dispose listeners

The problem was that throwing exceptions from dispose handlers
skipped most of dispose code in SWT, which caused various problems like
1) SWT believed that Widget is alive while OS believed that it's dead
2) Resources were disposed but Widgets continued to live
3) Shells vanished but SWT still thought that it's not disposed, causing
   exit conditions in loop to continue.
4) etc etc etc

This patch insulates SWT from exceptions in user's listeners on key
dispose paths. If an exception occurs, it's stashed away to be re-thrown
after SWT does the essential work. If there are multiple concurrent
exceptions, these are added to 'Throwable.addSuppressed()'.

This patch only insulates some paths while others (such as various
'Widget.disposeChildren()') remain for future patches.

It is unfortunate how code becomes polluted with try/catch blocks.
I considered implementing 'ExceptionStash.do(Runnable)' to hide the
boilerplate code, but that would mean throwing 2 more lines on
callstacks on many paths. I decided that it's not worth it.

Change-Id: Ia85ddca98e2a50a89e2c5cab47c9b3936f0a8a42
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182320
Tested-by: Platform Bot <platform-bot@eclipse.org>
Tested-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
15 files changed
tree: 9f70e89251de582db2ea224777f98f385531cde2
  1. bundles/
  2. container/
  3. examples/
  4. features/
  5. local-build/
  6. tests/
  7. .gitignore
  8. CONTRIBUTING
  9. LICENSE
  10. NOTICE
  11. pom.xml
  12. README.md
README.md

Contributing to SWT

Thanks for your interest in this project.

Developer resources:

See the following description for how to contribute a feature or a bug fix to SWT.

Information regarding source code management, builds, coding standards, and more and be found under the following link.

Contributor License Agreement:

Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).

Contact:

Contact the project developers via the project's “dev” list.

Search for bugs:

This project uses Bugzilla to track ongoing development and issues.

Create a new bug:

Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!