Bug 968958

Summary: Refactor unnecessary while loop in JndiAction class
Product: [Retired] oVirt Reporter: Tomas Dosek <tdosek>
Component: ovirt-engine-coreAssignee: Tomas Dosek <tdosek>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.2CC: acathrow, iheim, jkt, juan.hernandez, mperina
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 969114 (view as bug list) Environment:
Last Closed: 2013-09-23 07:27:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 969114    

Description Tomas Dosek 2013-05-30 11:17:58 UTC
Description of problem:

Please refactor following unnecessary while loop:

"
                    while (answer.hasMoreElements()) {
                        // Print the objectGUID for the user as well as URI and query path
                        String guid = guidFromResults(answer.next());
                        if (guid == null) {
                            break;
                        }
                        userGuid.append(guid);
                        logQueryContext(userGuid.toString(), uri.toString(), currentLdapServer);
                        return AuthenticationResult.OK;
                    }

"

In any case this loop runs only once so the problem solved by it can be
replaced by "if" decission statement.

Version-Release number of selected component (if applicable):
Any

Comment 1 Tomas Dosek 2013-05-30 11:31:13 UTC
Proposed patch:

if (answer.hasMoreElements()) {
    String guid = guidFromResults(answer.next());
    if (guid != null) {   
         userGuid.append(guid);
         logQueryContext(userGuid.toString(), uri.toString(), currentLdapServer);
         return AuthenticationResult.OK;
    }
}

Where logQueryContext procedure got added by http://gerrit.ovirt.org/#/c/15176/
to replace current weak logging options.

Comment 2 Tomas Dosek 2013-05-30 16:47:50 UTC
Propsed patch in gerrit: http://gerrit.ovirt.org/15217/

Comment 3 Itamar Heim 2013-08-21 16:43:06 UTC
as RC is built, moving to ON_QA (hopefully did not catch incorrect bugs when doing this)

Comment 4 Itamar Heim 2013-09-23 07:27:45 UTC
closing as this should be in 3.3 (doing so in bulk, so may be incorrect)