Commit ebcdcce
committed
Guard against the addition of null columns
And add a quick test that the problem is fixed.
This fix prevents cryptic exceptions like this one:
java.lang.NullPointerException: Cannot invoke "org.scijava.table.Column.size()" because "column" is null
at org.scijava.table.AbstractTable.add(AbstractTable.java:167)
at org.scijava.table.AbstractTable.add(AbstractTable.java:44)
at org.scijava.util.SizableArrayList.setSize(SizableArrayList.java:90)
at org.scijava.table.AbstractTable.setColumnCount(AbstractTable.java:75)
at org.scijava.table.AbstractTable.<init>(AbstractTable.java:66)
at org.scijava.table.DefaultFloatTable.<init>(DefaultFloatTable.java:49)
The above exception happens if too many initial columns are given,
because the SizableArrayList under the hood sometimes tries (if a certain
hack fails) to expand the size of the ArrayList by repeatedly adding nulls.
The new test checks that such tables can be created with lots of
initial columns, *and* that we can explicitly add null columns,
without this sort of exception getting thrown.1 parent 43de685 commit ebcdcce
File tree
2 files changed
+14
-4
lines changed- src
- main/java/org/scijava/table
- test/java/org/scijava/table
2 files changed
+14
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
307 | 317 | | |
308 | 318 | | |
309 | 319 | | |
| |||
0 commit comments