From 98b7ac3c69f631226e11dbd242025b49a811ea10 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Tue, 01 Apr 2008 11:34:19 +0000
Subject: [PATCH] Fix occansional null pointer exception when an ancestor dn hasn't yet been added to dn2id by another work thread. Also simplify buffer flushing at end of the import. Issue 3083.
---
opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java | 43 ++++++++++++++++++++++++++-----------------
1 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
index df81ca7..10f6fed 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
@@ -76,9 +76,6 @@
//The substring buffer manager to use.
private BufferManager bufferMgr;
- //Flag set when substring buffer should be flushed.
- private boolean flushBuffer = true;
-
/**
* Create a work thread instance using the specified parameters.
*
@@ -112,15 +109,6 @@
stopRequested = true;
}
-
- /**
- * Tells thread to flush substring buffer.
- *
- * @param flush Set to false if substring flush should be skipped.
- */
- void setFlush(boolean flush) {
- this.flushBuffer = flush;
- }
/**
* Run the thread. Read from item from queue and give it to the
* buffer manage, unless told to stop. Once stopped, ask buffer manager
@@ -143,9 +131,6 @@
}
}
} while (!stopRequested);
- if(flushBuffer) {
- bufferMgr.flushAll(threadNumber);
- }
} catch (Exception e) {
if (debugEnabled()) {
TRACER.debugCaught(DebugLogLevel.ERROR, e);
@@ -403,6 +388,7 @@
IDs.set(0, entryID);
}
else {
+ EntryID nodeID;
IDs = new ArrayList<EntryID>(entryDN.getNumComponents());
IDs.add(entryID);
if (parentID != null)
@@ -411,8 +397,11 @@
EntryContainer ec = context.getEntryContainer();
for (DN dn = ec.getParentWithinBase(parentDN); dn != null;
dn = ec.getParentWithinBase(dn)) {
- EntryID nodeID = dn2id.get(txn, dn);
- IDs.add(nodeID);
+ if((nodeID = getAncestorID(dn2id, dn, txn)) == null) {
+ return false;
+ } else {
+ IDs.add(nodeID);
+ }
}
}
}
@@ -422,6 +411,26 @@
return true;
}
+ private EntryID getAncestorID(DN2ID dn2id, DN dn, Transaction txn)
+ throws DatabaseException {
+ int i=0;
+ EntryID nodeID = dn2id.get(txn, dn);
+ if(nodeID == null) {
+ while((nodeID = dn2id.get(txn, dn)) == null) {
+ try {
+ Thread.sleep(50);
+ if(i == 3) {
+ return null;
+ }
+ i++;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ }
+ return nodeID;
+ }
+
/**
* Process the a entry from the work element into the dn2id DB.
*
--
Gitblit v1.10.0