Bug 968958 - Refactor unnecessary while loop in JndiAction class
Summary: Refactor unnecessary while loop in JndiAction class
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: oVirt
Classification: Retired
Component: ovirt-engine-core
Version: 3.2
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Tomas Dosek
QA Contact:
URL:
Whiteboard: infra
Depends On:
Blocks: 969114
TreeView+ depends on / blocked
 
Reported: 2013-05-30 11:17 UTC by Tomas Dosek
Modified: 2013-09-23 07:27 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 969114 (view as bug list)
Environment:
Last Closed: 2013-09-23 07:27:45 UTC
oVirt Team: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 15217 0 None None None Never

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)


Note You need to log in before you can comment on or make changes to this bug.