Bug 45067 - ensure target exceptions are properly logged
Summary: ensure target exceptions are properly logged
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Incubator (show other bugs)
Version: unspecified   Edit
Hardware: PC other
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Rafael Chaves CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 60267
Blocks:
  Show dependency tree
 
Reported: 2003-10-16 20:24 EDT by Rafael Chaves CLA
Modified: 2005-09-27 09:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Chaves CLA 2003-10-16 20:24:02 EDT
When logging InvocationTargetExceptions, the nested exception, which contains 
the real cause of the problem, is often omitted.

One approach is to always log the innermost exception (even with multiple 
levels of nesting). Another is to ensure that every frame for every exception 
in the chain is printed.
Comment 1 Rafael Chaves CLA 2003-10-16 20:24:44 EDT
One example is: bug 44735.
Comment 2 DJ Houghton CLA 2004-04-28 10:32:33 EDT
Does this mean that we should be changing code in the platform logger when
logging invocation target exceptions?
Comment 3 Rafael Chaves CLA 2004-04-28 10:56:25 EDT
We already do something like that for BundleExceptions (see
DefaultLog#getStackTrace). We could easily do the same for
InvocationTargetExceptions.

The (minor) problem with doing this is that nested exceptions may appear twice
in the log entry (once as generated by Throwable.printStackTrace, as in the bug
mentioned above, and again, written by us).

The other approach mentioned in the original report does not work with Java
1.3/eeminimum (programmatic access to stack trace frames was added in 1.4).

I guess this should be moved to Equinox.
Comment 4 Rafael Chaves CLA 2004-04-28 12:05:09 EDT
The resolution of this depends on bug 60267.
Comment 5 Rafael Chaves CLA 2004-04-28 12:35:30 EDT
Fixed. Released to HEAD. We will ensure the deepest exception is always logged
(will skip BundleExceptions/InvocationTargetExceptions). Example:

!ENTRY reference:file:d:/target/releasing/plugins/org.eclipse.core.runtime/ 0 0
Apr 28, 2004 12:23:39.40
!MESSAGE FrameworkEvent.ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in
org.eclipse.core.internal.runtime.PlatformActivator.start() of bundle
org.eclipse.core.runtime.
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:990)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:952)
	at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:408)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:373)
	at
org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:999)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:571)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:482)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:272)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:442)
	at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:153)
	at
org.eclipse.osgi.framework.eventmgr.EventThread$Queued.dispatchEvent(EventThread.java:56)
	at org.eclipse.osgi.framework.eventmgr.EventThread.run(EventThread.java:107)
Caused by: org.osgi.framework.BundleException: nested 1
	at
org.eclipse.core.internal.runtime.PlatformActivator.start(PlatformActivator.java:55)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:973)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:969)
	... 11 more
Caused by: java.lang.reflect.InvocationTargetException: nested 2
	... 15 more
Caused by: java.lang.RuntimeException: nested 3
	... 15 more
Root exception:
java.lang.RuntimeException: nested 3
	at
org.eclipse.core.internal.runtime.PlatformActivator.start(PlatformActivator.java:55)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:973)
	at java.security.AccessController.doPrivileged(Native Method)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:969)
	at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:952)
	at
org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:408)
	at
org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:373)
	at
org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:999)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:571)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:482)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:272)
	at
org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:442)
	at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:153)
	at
org.eclipse.osgi.framework.eventmgr.EventThread$Queued.dispatchEvent(EventThread.java:56)
	at org.eclipse.osgi.framework.eventmgr.EventThread.run(EventThread.java:107)

The "Caused by" stacks are written by Throwable#printStackTrace on Sun/IBM JDK
1.4.*. We write the "Root exception" after that, which is usually the most
important one.