From 9f63f0439a36954ce46507cbc0059135f3fff56f Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Fri, 23 Feb 2007 21:50:34 +0000
Subject: [PATCH] Recommit for issue 740. A debug logging helper method (EntryContainer#debugAccess) did not check for null OperationStatus objects being passed in and caused an NullPointerException whenever EntryCount was called. Added a null check.

---
 opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
index b8a5a52..33a5ef7 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/EntryContainer.java
@@ -1521,8 +1521,6 @@
         }
       }
 
-      // Increment the entry count.
-      id2entry.adjustRecordCount(txn, 1);
     }
 
     /**
@@ -2021,8 +2019,6 @@
       id2cBuffered.flush();
       id2sBuffered.flush();
 
-      // Decrement the entry count.
-      id2entry.adjustRecordCount(txn, -getDeletedEntryCount());
     }
 
     /**
@@ -3253,7 +3249,7 @@
    */
   public long getEntryCount() throws DatabaseException
   {
-    return id2entry.getRecordCount(null);
+    return id2entry.getRecordCount();
   }
 
   /**
@@ -3538,15 +3534,18 @@
     // DATABASE_READ/DATABASE_WRITE
     StringBuilder builder = new StringBuilder();
     builder.append(operation);
-    if (status == OperationStatus.SUCCESS)
+    if(status != null)
     {
-      builder.append(" (ok)");
-    }
-    else
-    {
-      builder.append(" (");
-      builder.append(status.toString());
-      builder.append(")");
+      if (status == OperationStatus.SUCCESS)
+      {
+        builder.append(" (ok)");
+      }
+      else
+      {
+        builder.append(" (");
+        builder.append(status.toString());
+        builder.append(")");
+      }
     }
     builder.append(" db=");
     builder.append(database.getDatabaseName());
@@ -3737,6 +3736,21 @@
   }
 
   /**
+   * Get the count of key/data pairs in the database in a JE database.
+   * This is a simple wrapper around the JE Database.count method.
+   * @param database the JE database handle.
+   * @return The count of key/data pairs in the database.
+   * @throws DatabaseException If an error occurs in the JE operation.
+   */
+  public static long count(Database database) throws DatabaseException
+  {
+    long count = database.count();
+    assert debugAccess("count", DATABASE_READ, null, database,
+        null, null, null);
+    return count;
+  }
+
+  /**
    * Remove a database from disk.
    *
    * @param name The short database name, to which the entryContainer name will

--
Gitblit v1.10.0