Tomáš Došek has uploaded a new change for review.

Change subject: engine: Fix for RHBZ#968958 - Refactor unnecessary while loop
......................................................................

engine: Fix for RHBZ#968958 - Refactor unnecessary while loop

Fixing unnecessary while loop in JndiAction class.
Under any circumstances the while loop runs only once,
hence it's not necessary and simple "if" statement can do the same.

Change-Id: I938726d631ac4ccb91cc68791e8e349dd43895ea
Bug-Url: https://bugzilla.redhat.com/968958
Signed-off-by: Tomas Dosek <[email protected]>
---
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/kerberos/JndiAction.java
1 file changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/15217/1

diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/kerberos/JndiAction.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/kerberos/JndiAction.java
index e30cd76..c3ea399 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/kerberos/JndiAction.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/kerberos/JndiAction.java
@@ -104,18 +104,16 @@
                     ctx = new InitialDirContext(env);
                     NamingEnumeration<SearchResult> answer = executeQuery(ctx, 
controls, prepareQuery());
 
-                    while (answer.hasMoreElements()) {
+                    if (answer.hasMoreElements()) {
                         // Print the objectGUID for the user as well as URI 
and query path
                         String guid = guidFromResults(answer.next());
-                        if (guid == null) {
-                            break;
+                        if (guid != null) {
+                            userGuid.append(guid);
+                            logQueryContext(userGuid.toString(), 
uri.toString(), currentLdapServer);
+                            return AuthenticationResult.OK;
                         }
-                        userGuid.append(guid);
-                        logQueryContext(userGuid.toString(), uri.toString(), 
currentLdapServer);
-                        return AuthenticationResult.OK;
-                    }
-                    // Print user GUID and another logging info only if it was 
not printed previously in while loop
-                    if (!answer.hasMoreElements()) {
+                    } else {
+                    // Print user GUID and another logging info only if it was 
not printed previously already
                         logQueryContext(userGuid.toString(), uri.toString(), 
currentLdapServer);
                     }
                     System.out.println("No user in Directory was found for " + 
userName


--
To view, visit http://gerrit.ovirt.org/15217
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I938726d631ac4ccb91cc68791e8e349dd43895ea
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomáš Došek <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to