Bug 968958 - Refactor unnecessary while loop in JndiAction class
Refactor unnecessary while loop in JndiAction class
Status: CLOSED CURRENTRELEASE
Product: oVirt
Classification: Community
Component: ovirt-engine-core (Show other bugs)
3.2
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Tomas Dosek
infra
:
Depends On:
Blocks: 969114
  Show dependency treegraph
 
Reported: 2013-05-30 07:17 EDT by Tomas Dosek
Modified: 2013-09-23 03:27 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 969114 (view as bug list)
Environment:
Last Closed: 2013-09-23 03:27:45 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 15217 None None None Never

  None (edit)
Description Tomas Dosek 2013-05-30 07:17:58 EDT
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 07:31:13 EDT
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 12:47:50 EDT
Propsed patch in gerrit: http://gerrit.ovirt.org/15217/
Comment 3 Itamar Heim 2013-08-21 12:43:06 EDT
as RC is built, moving to ON_QA (hopefully did not catch incorrect bugs when doing this)
Comment 4 Itamar Heim 2013-09-23 03:27:45 EDT
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.