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

Bug 162140

Summary: [Progress] Be more resilient to null args in StatusLine's progress monitor
Product: [Eclipse Project] Platform Reporter: Nick Edgar <n.a.edgar>
Component: UIAssignee: Tod Creasey <Tod_Creasey>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne, Tod_Creasey
Version: 3.2Keywords: helpwanted
Target Milestone: 3.4 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposal patch none

Description Nick Edgar CLA 2006-10-24 16:08:57 EDT
3.2

In an editor's save method, do the following with the progress monitor:
monitor.setTaskName(null);
monitor.subTask("foo");

It fails with an NPE on the second line of subTask, which is:
        if (fTaskName.length() == 0) {

Although IProgressMonitor is not spec'ed to accept null, several clients do pass null (e.g. Workspace.run, see bug 161464).

StatusLine protects itself against null in beginTask, and should probably also do so in setTaskName and subTask.
Comment 1 Jan-Hendrik Diederich CLA 2008-02-28 10:56:10 EST
Created attachment 91014 [details]
Proposal patch

This is a proposal patch. It throws a null-pointer exception if the string parameter is null. The other possible solution could be to ignore such strings.
But I think it's better to inform instantly about the error.
Comment 2 Tod Creasey CLA 2008-03-03 16:05:59 EST
As we accept null for beginTask (we convert it to an empty String) we should do the same here.

Generally throwing a RuntimeException should only be done for catastrophic failures.
Comment 3 Tod Creasey CLA 2008-03-04 08:22:33 EST
Fixed in build >20080304
Comment 4 Tod Creasey CLA 2008-03-24 15:03:00 EDT
Verified in  I20080323-2000
Comment 5 Kim Horne CLA 2008-05-16 14:29:38 EDT
Tod, did we use this patch in the end?
Comment 6 Tod Creasey CLA 2008-05-20 08:07:56 EDT
No we didn't - see comment #2. I went for a solution that did not throw an NPE.