-
Notifications
You must be signed in to change notification settings - Fork 41
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
base: master
Are you sure you want to change the base?
Fixed bug override globally configured pageSize variable in the middle of the code #299
Conversation
There was a problem hiding this 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
847c512
to
64e3dac
Compare
@davidcoutadeur I have understood the problem better and proposed a new fix. The commits have been squashed as requested. |
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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); | |||
|
There was a problem hiding this comment.
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()])); |
There was a problem hiding this comment.
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)}); |
There was a problem hiding this comment.
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.
#176