Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368478 - NPE in org.eclipse.wst.server.ui.editor.ServerEditorPart.doSaveAs() causes JUnit failure
Summary: NPE in org.eclipse.wst.server.ui.editor.ServerEditorPart.doSaveAs() causes JU...
Status: RESOLVED FIXED
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: wst.server (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.3.2   Edit
Assignee: Steven Hung CLA
QA Contact: Elson Yuen CLA
URL:
Whiteboard:
Keywords:
: 368731 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-12 13:46 EST by Steven Hung CLA
Modified: 2017-10-11 16:37 EDT (History)
1 user (show)

See Also:


Attachments
Patch v1.0 (3.95 KB, patch)
2012-01-25 14:17 EST, Steven Hung CLA
eyuen7: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Hung CLA 2012-01-12 13:46:10 EST
Build Identifier: M-3.3.2-20120112034052 and I-3.4.0-20120112024638

This issue is related to an NPA in ServerEditorPart.doSaveAs in the JUnit test org.eclipse.wst.server.ui.tests.AllTests

Reproducible: Always
Comment 1 Steven Hung CLA 2012-01-25 14:17:58 EST
Created attachment 210076 [details]
Patch v1.0

Overview of fix:
Added a null check for the commandManager and also handled other possible exceptions within the iterator for ServerEditorPageSectionFactories

Note: this JUnit issue does not occur on the R3_2_5 stream, since the doSaveAs() on this stream does not do anything. The issue occurs in R3_3, which is where these tests were run against.

Tests run:
1. Ensured ServerEditorCore.getServerEditorPageSectionFactories() would not return null, by hacking the code to return no results when checking for registry. This ensured that no null check is necessary for getting the iterator because an empty array would be returned
2. Ensured that when the commandManager is null, that the NPE was caught. This test was done by running the JUnit again, to ensure that it would not throw an NPE
3. Ensured that editors could be loaded successfully, by launching the server editor with Tomcat and verifying that the logic had not changed through the addition of the try/catch block and the NPE check
Comment 2 Elson Yuen CLA 2012-01-25 14:28:30 EST
Steven, thanks for submitting the patch.  Code released to 33M and HEAD.
Comment 3 Elson Yuen CLA 2012-01-25 15:25:21 EST
*** Bug 368731 has been marked as a duplicate of this bug. ***
Comment 4 Eclipse Genie CLA 2017-10-11 16:37:45 EDT
New Gerrit change created: https://git.eclipse.org/r/109091