Bug 73111
[osgi] Review the EclipseAdaptor#handleRuntimeException behavior so it filters exceptions
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 ae17931..e57bc7d 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 @@
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 c61aeab..1767afc 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.