Look maybe at the history of the file in svn.  I wouldn't be surprised if
something else was present in the loop before (something like a cast of o).
Or if you are lucky, you could even have a nice comment placed when this if
was inserted.

Gilles

> -----Original Message-----
> From: Maarten Coene [mailto:[EMAIL PROTECTED]
> Sent: jeudi 30 août 2007 13:09
> To: ivy-dev
> Subject: IVY-590
> 
> Hi,
> 
> jira issue IVY-590 reports a NullPointerException which is caused by the
> following code (selected can be null):
> 
>         public EvictionData(String rootModuleConf, IvyNode parent,
> ConflictManager conflictManager,
>                 Collection selected) {
>             this.rootModuleConf = rootModuleConf;
>             this.parent = parent;
>             this.conflictManager = conflictManager;
>             this.selected = selected;
>             for (Iterator iter = selected.iterator(); iter.hasNext();) {
>                 Object o = (Object) iter.next();
>                 if (!(o instanceof IvyNode)) {
>                     throw new IllegalArgumentException(
>                             "selected nodes must be instance of IvyNode.
> Found: "
>                                     + o.getClass().getName());
>                 }
>             }
>         }
> 
> 
> Several patches have been contributed to fix this NPE by checking the
> selected parameter for null before entering the for-loop. However, I would
> like to remove this for loop from the code, since the collection always
> contains IvyNodes.
> 
> Does someone has an idea why this instanceof-check has been added there?
> 
> regards,
> Maarten
> 
> 
> 
> 
> 
> __________________________________________________________________________
> __________
> Be a better Globetrotter. Get better travel answers from someone who
> knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545469

Reply via email to