From 71ee88697d285e8932a8dcab3ebc27c79387dd68 Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Mon, 08 Jun 2015 07:58:39 +0000
Subject: [PATCH] OPENDJ-2085 CR-7159 NullPointerException while importing data in an instance containing 2 backends

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java
index 3ec0521..42b2539 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Suffix.java
@@ -53,7 +53,19 @@
 
   private final List<DN> includeBranches, excludeBranches;
   private final DN baseDN;
+ /**
+  * If not null this is the original entry container for the suffix in the backend before the
+  * import begins.
+  * <p>
+  * Then its data is completely deleted only at the very end of the import when calling
+  * *Importer.switchEntryContainers().
+  */
   private final EntryContainer srcEntryContainer;
+  /**
+   * If {@link #srcEntryContainer} is null, it is the original entry container for the suffix in the
+   * backend. Otherwise it is a temporary entry container that will eventually replace the existing
+   * {@link #srcEntryContainer} at the end of the import.
+   */
   private final EntryContainer entryContainer;
   private final Object synchObject = new Object();
   private static final int PARENT_ID_SET_SIZE = 16 * 1024;
@@ -78,7 +90,7 @@
   {
     this.entryContainer = entryContainer;
     this.srcEntryContainer = srcEntryContainer;
-    this.baseDN = entryContainer.getBaseDN();
+    this.baseDN = srcEntryContainer != null ? srcEntryContainer.getBaseDN() : entryContainer.getBaseDN();
     if (includeBranches != null)
     {
       this.includeBranches = includeBranches;

--
Gitblit v1.10.0