Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 211350

Summary: [ErrorHandling] Need better error handling in PerspectiveRegistry
Product: [Eclipse Project] Platform Reporter: Raji Akella <raji>
Component: UIAssignee: Krzysztof Daniel <krzysztof.daniel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: krzysztof.daniel, peeman, pwebster
Version: 3.2.2Keywords: helpwanted
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Part one of solution
none
PatchToBeReleasedSoon none

Description Raji Akella CLA 2007-11-28 18:27:29 EST
Build ID: 3.2.2


In org.eclipse.ui.workbench plugin / org.eclipse.ui.internal.registry.PerspectiveRegistry, the loadCustom method has three problems :

1) If the xmlString is empty, as is happening in our product, reader = null, and the call to XMLMementor.createReadRoot(reader) fails because the reader = null
2) If the first perspective is found, reader will be set up. If the second perspective is not found (such as because of the problem in 1), then reader will still have a value, but it will be referencing a closed stream.
3) There is no information logged to the error log that will help to identify any problem -- all that is displayed is a dialog message
Comment 1 Pavel Halas CLA 2008-03-12 08:55:20 EDT
(1) applies to PerspectiveRegistry.getCustomPersp(String) too.
Comment 2 Raji Akella CLA 2008-05-08 13:41:10 EDT
Is there a fix fr this in 3.4?
Comment 3 Tod Creasey CLA 2008-05-08 13:53:35 EDT
No there is not currently.
Comment 4 Krzysztof Daniel CLA 2008-12-16 10:15:24 EST
Raji, Pavel,

could you place here reproduction steps? I'd like to create a fix :-)
Comment 5 Pavel Halas CLA 2008-12-17 05:33:48 EST
The first point problem occurs by calling a code like this...

try {
        PerspectiveRegistry perspRegistry = (PerspectiveRegistry) PlatformUI.getWorkbench().getPerspectiveRegistry();
        perspRegistry.getCustomPersp("SomeNonexistingPerspective");
} catch (Exception e) {
        e.printStackTrace();
}


Internally causes calling this with reader == null...
XMLMemento memento = XMLMemento.createReadRoot(reader);

Hope this helps.
Comment 6 Krzysztof Daniel CLA 2008-12-17 07:45:47 EST
Created attachment 120686 [details]
Part one of solution

Kevin,

can I take this bug?

This patch addresses concern 1 & 2 in the bug description and comment 1.
Guys, is it what you expect?

Patch for concern 3 will be created soon.
Comment 7 Pavel Halas CLA 2008-12-17 08:38:24 EST
> Guys, is it what you expect?
> 
> Patch for concern 3 will be created soon.
> 

Seems fine to me. Thanks.
Comment 8 Raji Akella CLA 2008-12-17 09:39:26 EST
Christopher, thanks. Looks fine.
Comment 9 Krzysztof Daniel CLA 2008-12-18 09:40:29 EST
Created attachment 120833 [details]
PatchToBeReleasedSoon
Comment 10 Krzysztof Daniel CLA 2008-12-19 06:51:56 EST
I'm taking this bug :-)
Comment 11 Krzysztof Daniel CLA 2008-12-19 06:53:34 EST
Slightly modified patch released to HEAD.