Ticket #1647 (closed defect: moved)
Opened 2013-02-01T15:21:00-06:00
Last modified 2013-03-20T11:49:06-05:00
Table row sizing bug
Reported by: | curtis | Owned by: | curtis |
---|---|---|---|
Priority: | major | Milestone: | imagej2-unscheduled |
Component: | Data Model | Version: | 2.0.0-beta6 |
Severity: | serious | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #1713 |
Description
There is a bug in the Table implementation, as illustrated by the following code:
import imagej.data.table.DefaultGenericTable; import imagej.data.table.GenericTable; public class TableBug { public static void main(final String[] args) throws Exception { final String first = "First"; final String second = "Second"; final int rowCount = 10; final GenericTable table = new DefaultGenericTable(); table.setRowCount(rowCount); table.appendColumn(first); table.appendColumn(second); for (int row = 0; row < rowCount; row++) { table.set(first, row, "1st:" + row); table.set(second, row, "2nd:" + row); } System.out.println(table); } }
It throws the following exception:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.set(ArrayList.java:337) at imagej.data.table.AbstractTable.set(AbstractTable.java:408) at TableBug.main(TableBug.java:18)
But if you move the setRowCount call after the two appendColumn calls, the code works.
Change History
comment:2 Changed 2014-08-12T01:17:06-05:00 by curtis
- Status changed from new to closed
- Resolution set to moved