This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 295547 - [context] NPE in MonitorUiPlugin when running unit test
Summary: [context] NPE in MonitorUiPlugin when running unit test
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 3.3.1   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 297583 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-11-19 00:46 EST by Steffen Pingel CLA
Modified: 2010-01-27 14:25 EST (History)
2 users (show)

See Also:


Attachments
patch that removes ShellLifeCycleListener (6.52 KB, patch)
2009-11-19 01:06 EST, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (1.61 KB, application/octet-stream)
2009-11-19 01:06 EST, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2009-11-19 00:46:15 EST
The init() method wrongfully assumes that there is an active workbench window.

java.lang.NullPointerException
        at org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin.init(MonitorUiPlugin.java:404)
        at org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin.start(MonitorUiPlugin.java:148)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
        at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:408)
        at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:111)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:211)
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:381)
        at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:33)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:454)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
[...]
Comment 1 Steffen Pingel CLA 2009-11-19 00:51:18 EST
What is the purpose of the ShellLifeCycleListener anyways? The implementation seems bogus, particularly if multiple windows are opened.

Also this line doesn't seem quite right: launchingWorkbenchWindow = getWorkbench().getActiveWorkbenchWindow();. Why not use the first window where is no active window?
Comment 2 Steffen Pingel CLA 2009-11-19 01:06:05 EST
Created attachment 152555 [details]
patch that removes ShellLifeCycleListener
Comment 3 Steffen Pingel CLA 2009-11-19 01:06:11 EST
Created attachment 152556 [details]
mylyn/context/zip
Comment 4 Shawn Minto CLA 2009-11-19 18:11:12 EST
(In reply to comment #1)
> What is the purpose of the ShellLifeCycleListener anyways? The implementation
> seems bogus, particularly if multiple windows are opened.

This doesn't seem to do anything useful at all anymore.  The ACTIVITY_STRUCTUREKIND_LIFECYCLE and the two deltas aren't used anywhere else in the code, so it seems that this is just dead code.

> Also this line doesn't seem quite right: launchingWorkbenchWindow =
> getWorkbench().getActiveWorkbenchWindow();. Why not use the first window where
> is no active window?

Yeah, using the first window should work here.  Would have to confirm that this would have the same behavior though.
Comment 5 Steffen Pingel CLA 2009-11-19 18:30:23 EST
(In reply to comment #4)
> (In reply to comment #1)
> > What is the purpose of the ShellLifeCycleListener anyways? The implementation
> > seems bogus, particularly if multiple windows are opened.
> 
> This doesn't seem to do anything useful at all anymore.  The
> ACTIVITY_STRUCTUREKIND_LIFECYCLE and the two deltas aren't used anywhere else
> in the code, so it seems that this is just dead code.

Mik, can you confirm that this is safe to delete?

> > Also this line doesn't seem quite right: launchingWorkbenchWindow =
> > getWorkbench().getActiveWorkbenchWindow();. Why not use the first window where
> > is no active window?
> 
> Yeah, using the first window should work here.  Would have to confirm that this
> would have the same behavior though.

The only place where this is used in Mylyn is the perspective manager. I don't even know if it's right that we only save/restore the perspective of the launching window. Shouldn't we manage all windows?

It also doesn't seem right that we hold on to the launching window throughout the whole life cycle of MonitorUiPlugin. What if the user closes the window, shouldn't the reference be discarded (or can that never happen to the launching window)?
We can try using the active window first if you think that is more accurate. I would thi
Comment 6 Shawn Minto CLA 2009-11-19 19:27:59 EST
(In reply to comment #5)
> > > Also this line doesn't seem quite right: launchingWorkbenchWindow =
> > > getWorkbench().getActiveWorkbenchWindow();. Why not use the first window
> where
> > > is no active window?
> >
> > Yeah, using the first window should work here.  Would have to confirm that
> this
> > would have the same behavior though.
> 
> The only place where this is used in Mylyn is the perspective manager. I don't
> even know if it's right that we only save/restore the perspective of the
> launching window. Shouldn't we manage all windows?
> 
> It also doesn't seem right that we hold on to the launching window throughout
> the whole life cycle of MonitorUiPlugin. What if the user closes the window,
> shouldn't the reference be discarded (or can that never happen to the launching
> window)?
> We can try using the active window first if you think that is more accurate. I
> would thi

I also see it used in the editor manager, but I assume that you have changed this with you changes to the editor mementos.  I don't think that i have a problem with removing this, but it is API, so we will have to depreciate it for now.
Comment 7 Steffen Pingel CLA 2009-11-27 18:49:13 EST
Committed patch.
Comment 8 Steffen Pingel CLA 2010-01-27 14:25:25 EST
*** Bug 297583 has been marked as a duplicate of this bug. ***