Run the following test class:
public static void main(final String[] args) throws IOException {
final RecordManager recman = RecordManagerFactory.createRecordManager("d:/temp/jdbm-db/db1");
final HTree tree = HTree.createInstance(recman);
recman.setNamedObject("test", tree.getRecid());
final HTreeMap<String,String> treeMap = tree.asMap();
for (int i = 0; i < 100; i++) {
treeMap.put(String.valueOf(i),String.valueOf(i));
}
recman.commit();
System.out.println("finished adding");
treeMap.clear();
recman.commit();
System.out.println("finished clearing");
}
It fails with:
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at jdbm.htree.HashDirectory$HDIterator.next2(HashDirectory.java:480)
at jdbm.htree.HashDirectory$HDIterator.next(HashDirectory.java:565)
at jdbm.htree.HTreeMap$1$2.ensureNext(HTreeMap.java:98)
at jdbm.htree.HTreeMap$1$2.next(HTreeMap.java:122)
at jdbm.htree.HTreeMap$1$2.next(HTreeMap.java:91)
at java.util.AbstractCollection.clear(AbstractCollection.java:395)
at java.util.AbstractMap.clear(AbstractMap.java:271)
at LocalTester.main(LocalTester.java:43)
Oddly enough, it works if the iterator is 100.
Original issue reported on code.google.com by jrivard on 7 Jan 2011 at 3:36
Original issue reported on code.google.com by
jrivard
on 7 Jan 2011 at 3:36