From 14f94c13789b8ace4eae258b5f1d64494518f9c3 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 21 Dec 2015 14:04:12 +0000
Subject: [PATCH] Remove null checks on returned values of Entry.get*Attribute*() methods.
---
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java | 69 ++++++++++++++++------------------
1 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
index 9b5e326..cabb3df 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -518,7 +518,7 @@
// Now we'll build the Historical object we want to construct
final EntryHistorical newHistorical = new EntryHistorical();
- if (histAttrWithOptionsFromEntry == null)
+ if (histAttrWithOptionsFromEntry.isEmpty())
{
// No historical attribute in the entry, return empty object
return newHistorical;
@@ -607,48 +607,43 @@
public static Iterable<FakeOperation> generateFakeOperations(Entry entry)
{
TreeMap<CSN, FakeOperation> operations = new TreeMap<>();
- List<Attribute> attrs = getHistoricalAttr(entry);
- if (attrs != null)
+ for (Attribute attr : getHistoricalAttr(entry))
{
- for (Attribute attr : attrs)
+ for (ByteString val : attr)
{
- for (ByteString val : attr)
+ HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString());
+ if (histVal.isADDOperation())
{
- HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString());
- if (histVal.isADDOperation())
+ // Found some historical information indicating that this entry was just added.
+ // Create the corresponding ADD operation.
+ operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry));
+ }
+ else if (histVal.isMODDNOperation())
+ {
+ // Found some historical information indicating that this entry was just renamed.
+ // Create the corresponding ADD operation.
+ operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry));
+ }
+ else
+ {
+ // Found some historical information for modify operation.
+ // Generate the corresponding ModifyOperation or update
+ // the already generated Operation if it can be found.
+ CSN csn = histVal.getCSN();
+ Modification mod = histVal.generateMod();
+ FakeOperation fakeOperation = operations.get(csn);
+
+ if (fakeOperation instanceof FakeModifyOperation)
{
- // Found some historical information indicating that this entry was just added.
- // Create the corresponding ADD operation.
- operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry));
- }
- else if (histVal.isMODDNOperation())
- {
- // Found some historical information indicating that this entry was just renamed.
- // Create the corresponding ADD operation.
- operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry));
+ FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation;
+ modifyFakeOperation.addModification(mod);
}
else
{
- // Found some historical information for modify operation.
- // Generate the corresponding ModifyOperation or update
- // the already generated Operation if it can be found.
- CSN csn = histVal.getCSN();
- Modification mod = histVal.generateMod();
- FakeOperation fakeOperation = operations.get(csn);
-
- if (fakeOperation instanceof FakeModifyOperation)
- {
- FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation;
- modifyFakeOperation.addModification(mod);
- }
- else
- {
- String uuidString = getEntryUUID(entry);
- FakeModifyOperation modifyFakeOperation =
- new FakeModifyOperation(entry.getName(), csn, uuidString);
- modifyFakeOperation.addModification(mod);
- operations.put(histVal.getCSN(), modifyFakeOperation);
- }
+ String uuidString = getEntryUUID(entry);
+ FakeModifyOperation modifyFakeOperation = new FakeModifyOperation(entry.getName(), csn, uuidString);
+ modifyFakeOperation.addModification(mod);
+ operations.put(histVal.getCSN(), modifyFakeOperation);
}
}
}
@@ -747,7 +742,7 @@
*/
private static String extractEntryUUID(List<Attribute> entryUUIDAttributes, DN entryDN)
{
- if (entryUUIDAttributes != null)
+ if (!entryUUIDAttributes.isEmpty())
{
Attribute uuidAttr = entryUUIDAttributes.get(0);
if (!uuidAttr.isEmpty())
--
Gitblit v1.10.0