sagarswathi / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

[MVStore] org.h2.mvstore.Cursor throws java.lang.NullPointerException #461

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
H2 Version: svn trunk

Test:
==========================================
package my.test.mvstore.bugs;

import org.h2.mvstore.Cursor;
import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore;

public class TestCursorSkip {
    public static void main(String[] args) {
        MVStore store = MVStore.open(null);
        MVMap<Integer, String> map = store.openMap("MVMapTest");

        int n = 100;
        for (int i = 1; i <= n; i++) {
            map.put(i, "" + i);
        }

        Cursor<Integer> c = map.keyIterator(50);
        c.skip(40);
        while (c.hasNext()) {
            System.out.println(c.next());
        }
    }
}

Exception Stacktrace:
===============
Exception in thread "main" java.lang.NullPointerException
    at org.h2.mvstore.Page.getChildPageCount(Page.java:878)
    at org.h2.mvstore.MVMap.getChildPageCount(MVMap.java:1078)
    at org.h2.mvstore.Cursor.fetchNext(Cursor.java:116)
    at org.h2.mvstore.Cursor.next(Cursor.java:34)
    at my.test.mvstore.bugs.TestCursorSkip.main(TestCursorSkip.java:20)

Original issue reported on code.google.com by zhh200...@gmail.com on 12 May 2013 at 7:35

GoogleCodeExporter commented 8 years ago
Hi,

Thanks! I have fixed this now (not yet committed). The problem was that 
skip(..) didn't reset the stack of the cursor.

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 14 May 2013 at 7:38

GoogleCodeExporter commented 8 years ago
Fixed in version 1.3.172.

Original comment by thomas.t...@gmail.com on 25 May 2013 at 1:48