Bug 26948 - Requesting invalid target execution causes NPE in ProgressBuildListener
Summary: Requesting invalid target execution causes NPE in ProgressBuildListener
Status: CLOSED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 2.1   Edit
Hardware: PC All
: P2 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Darin Swanson CLA
QA Contact:
URL:
Whiteboard:
Keywords: core
Depends on:
Blocks:
 
Reported: 2002-11-22 10:03 EST by Jared Burns CLA
Modified: 2002-11-25 16:59 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2002-11-22 10:03:10 EST
If an invalid target name is passed into the ProgressBuildListener constructor,
an NPE occurs in countTarget(...). This is because the loop which stores the
Target objects in an array doesn't check if
mainProject.getTargets().get(targetName) returns null.
Comment 1 Jared Burns CLA 2002-11-22 10:04:53 EST
Fixed. I changed the implementation to use a List of targets and to only add
the target to the list if it is not null.

Please verify.
Comment 2 Darin Swanson CLA 2002-11-24 21:43:06 EST
I verified the code change but isn't the bug in passing a name to the build 
listener that does not exist.  We had this bug logged (bug 23350) before and 
you and I decided not to handle this case. 
Do you have a different use case now?
Comment 3 Jared Burns CLA 2002-11-24 22:13:39 EST
During the migration to launch configs I found that if I just passed in "arg1"
as an argument, it was interpreted as a target name and caused this NPE.
Comment 4 Darin Swanson CLA 2002-11-25 09:42:05 EST
The arg should be interpreted as a target name.
We seem to be doing a lot of work for a build that will fail (should exit 
with "Target 'arg' does not exist in this project").  We should check the 
validity of the target names and bail as soon as possible from the build.
Creating a progress monitor seems like overkill.
Comment 5 Darin Swanson CLA 2002-11-25 15:31:08 EST
Opened bug 27123 as the problem is really elsewhere.
I am going to remove the null check.
Comment 6 Darin Swanson CLA 2002-11-25 16:59:09 EST
So I was wrong...the easiest path for this is too handle the target that does 
not exist. We bail about as soon as we can.