when dynamically removing aggregates, there seems to be a problem with the iterators over the aggregated items used in AggregateTable's clearAggregateMappings : it seems that Entry instances in AbstractTreeMap for the rows of the aggregate table are sometimes created more than once, resulting in iterators whose "end" field is not the same instance as the last correct "next" element of the iterator.
As a result, the hasNext test falsely returns true (AggregateTable.java, line 514):
{{{
public boolean hasNext() {
return next != end;
}
}}}
causing the underlying iterator to continue past the end and eventually (at the end of all rows of the aggregate table) to throw an exception upon finding NIL.
although the problem might be the duplicate creation of Entry instances, the following works as a fix:
{{{
public boolean hasNext() {
return !next.equals(end);
}
}}}
Debugger session in IDEA showing the problem