From fed3bcd2aa96e5c18153cfce92c3504eaff98b2b Mon Sep 17 00:00:00 2001 From: Pascal Rapicault Date: Thu, 2 Sep 2004 22:07:45 +0000 Subject: Bug 73111 [osgi] Review the EclipseAdaptor#handleRuntimeException behavior so it filters exceptions --- .../eclipse/core/runtime/adaptor/EclipseAdaptor.java | 20 ++++++++++++++++---- .../adaptor/EclipseAdaptorMessages.properties | 3 ++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java index ae179313f..e57bc7db4 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptor.java @@ -551,25 +551,37 @@ public class EclipseAdaptor extends DefaultAdaptor { stopper.stopBundles(); } + private boolean isFatalException(Throwable error) { + if (error instanceof VirtualMachineError) { + return true; + } + if (error instanceof ThreadDeath) { + return true; + } + return false; + } + public void handleRuntimeError(Throwable error) { try { // check the prop each time this happens (should NEVER happen!) exitOnError = Boolean.valueOf(System.getProperty(PROP_EXITONERROR, "true")).booleanValue(); //$NON-NLS-1$ String message = EclipseAdaptorMsg.formatter.getString("ECLIPSE_ADAPTOR_RUNTIME_ERROR"); //$NON-NLS-1$ + if (exitOnError && isFatalException(error)) + message += ' ' + EclipseAdaptorMsg.formatter.getString("ECLIPSE_ADAPTOR_EXITING"); //$NON-NLS-1$ FrameworkLogEntry logEntry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, message, 0, error, null); frameworkLog.log(logEntry); } catch (Throwable t) { - // we may be in a currupted state and must be able to handle any errors (ie OutOfMemoryError) + // we may be in a corrupted state and must be able to handle any errors (ie OutOfMemoryError) // that may occur when handling the first error; this is REALLY the last resort. try { - error.printStackTrace(); - t.printStackTrace(); + error.printStackTrace(System.err); + t.printStackTrace(System.err); } catch (Throwable t1) { // if we fail that then we are beyond help. } } finally { // do the exit outside the try block just incase another runtime error was thrown while logging - if (exitOnError) + if (exitOnError && isFatalException(error)) System.exit(13); } } diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptorMessages.properties b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptorMessages.properties index c61aeabb3..1767afc6e 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptorMessages.properties +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseAdaptorMessages.properties @@ -14,7 +14,8 @@ #EclipseAdaptor messages ECLIPSE_ADAPTOR_ERROR_RM_CACHE=Cannot clean the cache directory {0}. ECLIPSE_ADAPTOR_ERROR_XML_SERVICE=Error registering XML parser services. -ECLIPSE_ADAPTOR_RUNTIME_ERROR=An unexpected runtime error has occurred. The application will terminate. +ECLIPSE_ADAPTOR_RUNTIME_ERROR=An unexpected runtime error has occurred. +ECLIPSE_ADAPTOR_EXITING=The application will terminate. #EclipseStarter messages ECLIPSE_STARTUP_BUNDLE_NOT_FOUND=Bundle {0} not found. -- cgit v1.2.3