Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 282874 - [ViewMgmt] [ActivityMgmt] NullpointerException during saving state of view registry with disabled xp based activities
Summary: [ViewMgmt] [ActivityMgmt] NullpointerException during saving state of view re...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5.1   Edit
Assignee: Boris Bokowski CLA
QA Contact: Boris Bokowski CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 283479
  Show dependency tree
 
Reported: 2009-07-08 11:16 EDT by Sascha Zak CLA
Modified: 2009-08-31 03:25 EDT (History)
3 users (show)

See Also:
remy.suen: review+


Attachments
Stack trace (5.29 KB, text/plain)
2009-07-09 03:16 EDT, Sascha Zak CLA
no flags Details
Stack trace after local fix of the original problem (5.37 KB, text/plain)
2009-07-10 04:35 EDT, Sascha Zak CLA
no flags Details
Patch for both ViewFactory and Perspective null check (2.01 KB, text/plain)
2009-07-13 01:57 EDT, Sascha Zak CLA
bokowski: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Zak CLA 2009-07-08 11:16:47 EDT
I'm using expression based activities and perspectives to provide UI elements depending on a user's role. Login/logout sets a variable of a custum source provider describing the user's role and triggers the expressions used to enable/disable some activies. After successful login a role specific perspective is shown.

After logout (also implicitly done before closing the workbench) with disabling the acitivies and closing the workbench ViewRegistry#saveState(IMemento) raises a NullPointerException.

The line

287 IViewDescriptor desc = viewReg.find(refs[i].getId());

returns null because of the (during logout) disabled activities for views that were part of the role specific perspective and subsequent causes the NullPointerException.

From my point of view this has to be at least checked against null.
Comment 1 Susan McCourt CLA 2009-07-08 14:11:00 EDT
What version of the source are you looking at?  I don't see a method ViewRegistry.saveState(IMemento) in 3.4 or 3.5 stream.  Can you attach the stack trace?
Comment 2 Sascha Zak CLA 2009-07-09 03:16:56 EDT
Created attachment 141159 [details]
Stack trace
Comment 3 Sascha Zak CLA 2009-07-09 03:18:41 EDT
I'm sorry, it is the ViewFactory class instead of ViewRegistry.
I'm using 3.5 (Galileo Release from June, 24th).
Stack trace is attached.

(In reply to comment #1)
> What version of the source are you looking at?  I don't see a method
> ViewRegistry.saveState(IMemento) in 3.4 or 3.5 stream.  Can you attach the
> stack trace?
> 

Comment 4 Boris Bokowski CLA 2009-07-09 11:59:30 EDT
Would you be able to contribute a patch?
Comment 5 Sascha Zak CLA 2009-07-10 04:32:24 EDT
(In reply to comment #4)
> Would you be able to contribute a patch?

I'm not sure how to contribute a patch. If this means to provide a fixed source file, class file or plugin jar, then I am. Otherwise please tell me what you expect.

I have checked out the corresponding code, added the described null check and tested it running into the next NullPointerException while saving the perspective state (now instead of viewstate) because of the same problem (IViewDescriptor is null because of disabled xp activities). I'll attach this stack trace too.

This leads me to the assumption, that there has to be generally thought about dealing with expression based activities and UI elements that may be no longer available when disabling such activites.


 

Comment 6 Sascha Zak CLA 2009-07-10 04:35:07 EDT
Created attachment 141272 [details]
Stack trace after local fix of the original problem
Comment 7 Boris Bokowski CLA 2009-07-10 13:55:05 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Would you be able to contribute a patch?
> 
> I'm not sure how to contribute a patch. If this means to provide a fixed source
> file, class file or plugin jar, then I am. Otherwise please tell me what you
> expect.

Sorry, I should have given you the pointer right away: http://wiki.eclipse.org/Platform_UI/How_to_Contribute#Creating_a_Patch
Comment 8 Sascha Zak CLA 2009-07-13 01:57:14 EDT
Created attachment 141390 [details]
Patch for both ViewFactory and Perspective null check
Comment 9 Boris Bokowski CLA 2009-07-14 22:24:53 EDT
(In reply to comment #5)
> This leads me to the assumption, that there has to be generally thought about
> dealing with expression based activities and UI elements that may be no longer
> available when disabling such activites.

I agree that this is not yet a well-tested mechanism. Thanks for filing this bug and attaching a patch, looking forward to more of those! ;-)
Comment 10 Remy Suen CLA 2009-07-14 22:49:41 EDT
Patch looks fine and safe and I also learned something new from it! Grrrrrrrrrrreat!

Thanks for your contribution, Sascha!
Comment 11 Boris Bokowski CLA 2009-07-14 23:00:42 EDT
Released to R3_5_maintenance.
Comment 12 Boris Bokowski CLA 2009-08-27 17:04:14 EDT
Sascha, would you be able to verify that the NPE does not occur anymore when using a 3.5.1 candidate build?
Comment 13 Sascha Zak CLA 2009-08-31 03:25:10 EDT
(In reply to comment #12)
> Sascha, would you be able to verify that the NPE does not occur anymore when
> using a 3.5.1 candidate build?

I like to verify it, but please give me a few days, I'm currently very busy...