Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug override globally configured pageSize variable in the middle of the code #299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abpai94
Copy link
Collaborator

@abpai94 abpai94 commented Jul 26, 2024

@abpai94 abpai94 self-assigned this Jul 26, 2024
@coudot coudot requested a review from soisik July 26, 2024 10:58
@coudot coudot removed their request for review August 27, 2024 08:55
@coudot coudot added this to the 2.2 milestone Aug 27, 2024
@coudot coudot added the bug label Aug 27, 2024
@coudot coudot changed the title #176: Fixed bug override globally configured pageSize variable in the middle of the code. Fixed bug override globally configured pageSize variable in the middle of the code Aug 27, 2024
Copy link
Contributor

@soisik soisik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Abishek,
Check out doGetAttrsList method, we seem to have lost paginated load of pivots (only first paged loaded ?) and some control are not passed on anymore.
To reproduce issue, one should have a LDAP directory with many users ( + 2000), a pageSize at 500, and an olcLimits should apply for the account that connect to source.
There when searching for over olcLimits in a dataset (for members for example), you should see less entry returns than expected (as they are limited by olcLimits), while one should expect a paginated load of theses entries so that olcLimits is not reach and no entry is missed.

- Removed code that resets pagination
- Maintains pagination and sortedBy for multiple context requests
@abpai94 abpai94 force-pushed the 176-bug-dn-elements-max-pagesize branch from 847c512 to 64e3dac Compare September 4, 2024 13:57
@abpai94
Copy link
Collaborator Author

abpai94 commented Sep 4, 2024

@davidcoutadeur I have understood the problem better and proposed a new fix. The commits have been squashed as requested.

@abpai94 abpai94 requested a review from soisik September 4, 2024 14:38
Copy link
Contributor

@davidcoutadeur davidcoutadeur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my complete review

pageSize = -1;
}
// Setting global pageSize and sortedBy variable
contextRequestControls();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must not set controls globally, as they are specific to search operations.

Here, you just have to set the pageSize and sortedBy properties. (I think the original code was ok)

while (ne.hasMoreElements()) {
iist.add(((SearchResult) ne.next()).getName() + completedBaseDn);
}
byte[] pagedResultsResponse = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this function, you should:

  • call a new function setsearchcontrols() before the search. This function would set the pagesize and sortedby controls
  • call a new function clearsearchcontrols() after the search. This function would get the current controls (with getRequestControls), and remove only the paged and sortedby controls if they exist

}
pagedResultsResponse = pagination();
} while (pagedResultsResponse != null);
contextRequestControls();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one seems useless

}
pagedResultsResponse = pagination();
} while (pagedResultsResponse != null);
contextRequestControls();
} catch (NamingException e) {
LOGGER.error(e.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in every catch structure, you should cal the clearsearchcontrols function to ensure the controls are removed (see my comment below for more details about this function)

@@ -1135,30 +1136,8 @@ public Map<String, LscDatasets> doGetAttrsList(final String base,
constraints.setReturningAttributes(attributes);
constraints.setSearchScope(scope);
constraints.setReturningObjFlag(true);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as previous:

In this function, you should:

  • call a new function setsearchcontrols() before the search. This function would set the pagesize and sortedby controls
  • call a new function clearsearchcontrols() after the search. This function would get the current controls (with getRequestControls), and remove only the paged and sortedby controls if they exist. And also take care to call the clearsearchcontrols in the catch clauses.

if (sortedBy != null) {
List<SortControl> requestControls = new ArrayList<>();
requestControls.add(new SortControl(sortedBy, Control.CRITICAL));
ctx.setRequestControls(requestControls.toArray(new Control[requestControls.size()]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I think you should prepare a global requestControls list, and call setRequestControls only once.

}
if (pagedResultsResponse != null) {
ctx.setRequestControls(new Control[]{
new PagedResultsControl(pageSize, pagedResultsResponse, Control.CRITICAL)});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but here maybe you should get the previous controls, remove any previous pagedcontrol, and add the new pagedcontrol with the cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

list of DN elements is truncated when using search method on JndiService
4 participants