Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323179 - [Table] Creating and disposing a TableColumn (without updating the TableItems) results in an ArrayIndexOutOfBoundsException
Summary: [Table] Creating and disposing a TableColumn (without updating the TableItems...
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.4 M2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-19 14:00 EDT by Istvan Ballok CLA
Modified: 2010-08-23 05:16 EDT (History)
1 user (show)

See Also:


Attachments
an RWT code snippet to reproduce the problem (1.90 KB, application/octet-stream)
2010-08-19 14:00 EDT, Istvan Ballok CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Istvan Ballok CLA 2010-08-19 14:00:24 EDT
Created attachment 177033 [details]
an RWT code snippet to reproduce the problem

Creating and disposing a TableColumn results in an ArrayIndexOutOfBoundsException,
if all the items of the Table were not updated after creating the column by e.g. calling TableItem#setText(int, string)

Although it could be disputed, how meaningful this is - this problem is the gist of a bug that we had in our application; 
However, the AIOOB exception at runtime is certainly not the expected behaviour.

Please find the attached snippet to reproduce the problem.

Hint:
When disposing the column, the column is destroyed in the table (see Table#destroyColumn(TableColumn)) that removes the corresponding cell data from the table items (see TableItem#removeData(int)).
The problem is that the TableItem#data Data[] array's length was not adjusted when the column was created and hence the precondition of the #removeData method is not met: the data array does not contain the index-th element that is to be removed.

Note: the TableItem#data array's length is adjusted e.g. in TableItem#setText(int, String) by calling TableItem#ensureData(int, int).

In accordance with that, this problem happens only if e.g. TableItem#setText(int, string) is not called on all the TableItems in the Table after the new column was created and before it is disposed.

Note: SWT on win32 does not have any problems with this snippet.
Comment 1 Ivan Furnadjiev CLA 2010-08-23 05:16:56 EDT
Fixed in CVS HEAD. Test case added.