5 Replies Latest reply on Jun 16, 2010 1:53 PM by Charles Lamb

    NullPointerException in Database.put

      On inserting a key/value pair into previously cleared Database (e. g. tables were purged and successfuly saved in another successfully comitted transaction considerable time before) I get an NPE.

      at com.sleepycat.je.tree.IN.computeKeyPrefix(IN.java:767)
      at com.sleepycat.je.tree.IN.setKeyAndPrefix(IN.java:681)
      at com.sleepycat.je.tree.IN.insertEntry1(IN.java:2001)
      at com.sleepycat.je.tree.Tree.insert(Tree.java:2488)
      at com.sleepycat.je.dbi.CursorImpl.put(CursorImpl.java:1084)
      at com.sleepycat.je.Cursor.putAllowPhantoms(Cursor.java:1789)
      at com.sleepycat.je.Cursor.putNoNotify(Cursor.java:1746)
      at com.sleepycat.je.Cursor.putNotify(Cursor.java:1679)
      at com.sleepycat.je.Cursor.putInternal(Cursor.java:1616)
      at com.sleepycat.je.Database.putInternal(Database.java:1180)
      at com.sleepycat.je.Database.put(Database.java:1052)

      This code in IN.java (bdb je 4.0.92) obviously causes this NPE if current IN is empty:

      int startIdx = 1;
      byte[] curPrefixKey = null;
      if (excludeIdx == 0) {
      startIdx = 2;
      curPrefixKey = getKey(1);
      } else {
      curPrefixKey = getKey(0);

      int prefixLen = curPrefixKey.length;
      for (int i = startIdx; i < nEntries; i ) {
      byte[] curKey = getKey(i);
      if (curPrefixKey == null || curKey == null) {
      return null;

      I'm running ubuntu linux with SUN JDK (1.6.0_14).

      P. S. Most likely, the problem is more sophisticated since it goes away after restart, so this empty IN in which the key belongs exists only in memory.

      P. P. S. I can reproduce this NPE in my setup, so feel free to ask for additional details.