From cdbc97a66ca18d9f74b58c3fbca253f17d4dcd55 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 02 Feb 2016 10:57:43 +0000
Subject: [PATCH] Code cleanups: - remove isEmpty() checks when lists are iterated immediately after - extracted methods - removed {@inheritDoc} javadocs

---
 opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
index 8779018..080d088 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
@@ -36,13 +36,13 @@
 import org.forgerock.opendj.ldap.ModificationType;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
 import org.opends.server.protocols.internal.InternalSearchOperation;
 import org.opends.server.protocols.internal.Requests;
 import org.opends.server.protocols.internal.SearchRequest;
 import org.opends.server.types.Attribute;
-import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.opends.server.types.Attributes;
 import org.opends.server.types.DN;
 import org.opends.server.types.DirectoryException;
@@ -250,20 +250,19 @@
     }
 
     // Read the port from the PORT attribute
-    SearchResultEntry adminConnectorEntry = null;
     LinkedList<SearchResultEntry> result = search.getSearchEntries();
     if (!result.isEmpty())
     {
-      adminConnectorEntry = result.getFirst();
+      SearchResultEntry adminConnectorEntry = result.getFirst();
+      AttributeType attrType = DirectoryServer.getAttributeType(attrName);
+      List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType);
+      if (!attrs.isEmpty())
+      {
+        // Get the attribute value
+        return attrs.get(0).iterator().next().toString();
+      }
     }
 
-    AttributeType attrType = DirectoryServer.getAttributeType(attrName);
-    List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType);
-    if (!attrs.isEmpty())
-    {
-      // Get the attribute value
-      return attrs.get(0).iterator().next().toString();
-    }
     // Can not happen. Best effort.
     // TODO Log an Error.
     return null;

--
Gitblit v1.10.0