Ticket #1647 (closed defect: moved)

Opened 5 years ago

Last modified 5 years ago

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:1 Changed 5 years ago by bdezonia

  • Blocking 1713 added

comment:2 Changed 3 years ago by curtis

  • Status changed from new to closed
  • Resolution set to moved
Note: See TracTickets for help on using tickets.