Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 294654 - [TreeItem] doesn't handle invalid index within parent item
Summary: [TreeItem] doesn't handle invalid index within parent item
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.3 M4   Edit
Assignee: Dominik Ebert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-09 14:23 EST by Benjamin Muskalla CLA
Modified: 2009-12-04 06:06 EST (History)
2 users (show)

See Also:


Attachments
First draft (4.11 KB, patch)
2009-11-27 10:44 EST, Dominik Ebert CLA
ruediger.herrmann: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Muskalla CLA 2009-11-09 14:23:08 EST
Create a new TreeItem with another item as parent and an invalid index. According to the javadoc we should throw an exception in this case.

To be added to testConstructor:

    try {
      new TreeItem( item, SWT.NONE, 5 );
      fail( "No exception thrown for illegal index argument" );
    } catch( IllegalArgumentException e ) {
    }
Comment 1 Dominik Ebert CLA 2009-11-27 10:44:19 EST
Created attachment 153250 [details]
First draft

I changed the logic of TreeItem( Tree ,TreeItem, style, index ).
The constructor throws an IAE if the index is not valid.
Valid arguments are all values between 0 and the number of Items in the parent (inclusive).
In the old version, -1 was a valid argument and an indicator to add the created TreeItem at the end of the parent's array.
In this Patch, an IAE is thrown if index == -1, too.
I used the SWT implementation of TreeItem as a guide for valid arguments.
In that implementation, -1 throws an IAE, and the highest valid index argument is parent.getItemCount().
Comment 2 Rüdiger Herrmann CLA 2009-12-04 06:06:34 EST
Applied patch to CVS HEAD