From 65e3293e0a58e31471ddaadfc137dad3bb9b239b Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 23 Mar 2015 10:12:49 +0000
Subject: [PATCH] Ensured IndexQuery.evaluate() never returns null + updated javadoc to mention it. Client code assumes that the returned value will never be null anyway.
---
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java | 35 ++++++++++++++---------------------
1 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
index e53003b..5ab51cc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
@@ -409,39 +409,32 @@
if (value != null)
{
EntryIDSet entryIDSet = newSetFromBytes(key, value);
- if (!entryIDSet.isDefined())
+ if (entryIDSet.isDefined())
{
- return ConditionResult.UNDEFINED;
+ return ConditionResult.valueOf(entryIDSet.contains(entryID));
}
- return ConditionResult.valueOf(entryIDSet.contains(entryID));
- }
- else if (trusted)
- {
- return ConditionResult.FALSE;
- }
- else
- {
return ConditionResult.UNDEFINED;
}
+ return trusted ? ConditionResult.FALSE : ConditionResult.UNDEFINED;
}
+ /**
+ * Reads the value associated to a key.
+ *
+ * @param txn The transaction to use for the operation
+ * @param key The key to read
+ * @return The non null set of entry IDs.
+ */
EntryIDSet read(ReadableStorage txn, ByteSequence key)
{
try
{
ByteString value = txn.read(getName(), key);
- if (value == null)
+ if (value != null)
{
- if(trusted)
- {
- return newDefinedSet();
- }
- else
- {
- return newUndefinedSet();
- }
+ return newSetFromBytes(key, value);
}
- return newSetFromBytes(key, value);
+ return trusted ? newDefinedSet() : newUndefinedSet();
}
catch (StorageRuntimeException e)
{
@@ -471,7 +464,7 @@
* strictly less than the upper bound are included.
* This value is ignored if the upper bound is not
* specified.
- * @return The set of entry IDs.
+ * @return The non null set of entry IDs.
*/
EntryIDSet readRange(ReadableStorage txn,
ByteSequence lower, ByteSequence upper, boolean lowerIncluded, boolean upperIncluded)
--
Gitblit v1.10.0