Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTreeMap.clear() fails on maps with ConcurrentModificationException #2

Closed
GoogleCodeExporter opened this issue Aug 7, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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

@GoogleCodeExporter
Copy link
Author

Issue fixed with commit r63 http://code.google.com/p/jdbm2/source/detail?r=63

New should be in a week.


Original comment by kja...@gmail.com on 22 Jan 2011 at 5:26

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant