-
Notifications
You must be signed in to change notification settings - Fork 153
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
[JENKINS-55803] - Attempt to solve issue:removing the intermediate collections created each time getRolesHavingPermission() is invoked #54
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.
@deepanshnagaria could you please the formatting?
In Java the common formatting is
if (something) {
// ...
} else if (somethingElse) {
// ...
} else {
// ..
}
The logic itself looks Ok
if(this.grantedRoles.get(role).contains(sid)) { | ||
final Set<Permission> permissions = new HashSet<>(); | ||
final Permission per = p; | ||
final boolean[] temp = {false}; |
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.
Optional would be recommended, but ok
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.
Sir i didn't understand.... Can you clarify a bit....?
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.
Sorry for the issue in formatting i took reference from if else instead of this: (. I shall do that. Sorry again for repeated issues in formatting, i shall try to ignore further such issues. |
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.
The logic looks ok,only some formatting problems.
And I was wondering if I could break the walker when the perform was true, just a possible improve.
// Walk through the roles, and only add the roles having the given permission, | ||
// or a permission implying the given permission | ||
new RoleWalker() { | ||
public void perform(Role current) { |
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.
It would be better to add an overide annotation here.
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.
sure
@runzexia I myself thought of breaking the RoleWalker but with current implementation it doesn't seem to be possible. But we can do the same by not calling the RoleWalker and implementing the logic of walk function, that could be done. Should I do that? |
I think you can try to do that, I don't know how oleg thinks, this PR already looks good. |
I shall do that in the next commit, it won't take much i think. Thanks for the review. |
@runzexia this commit contains changes for breaking the loop. cc: @oleg-nenashev |
Yes, breaking the cycle will be an interesting change RoleWalker is a part of the plugin codebase: role-strategy-plugin/src/main/java/com/michelin/cio/hudson/plugins/rolestrategy/RoleMap.java Lines 415 to 436 in 529512e
My suggestion would be to create a follow-up ticket to support breaking the cycle from |
@oleg-nenashev I have created an issue https://issues.jenkins-ci.org/browse/JENKINS-55916 adding a point for memory, do tell if changes are required. |
I have updated this commit in sink with changes in #58 please suggest changes if required. @runzexia @oleg-nenashev |
src/main/java/com/michelin/cio/hudson/plugins/rolestrategy/RoleMap.java
Outdated
Show resolved
Hide resolved
src/main/java/com/michelin/cio/hudson/plugins/rolestrategy/RoleMap.java
Outdated
Show resolved
Hide resolved
@deepanshnagaria there is a minor merge conflict after integration of other PRs. Are you able to resolve it? Or do you need some assistance? |
yeah i shall do resolve that. |
ignore last commit pls |
@deepanshnagaria could you please configure your IDE to disable automatic code reformatting? Even if the code formatting is not good, massive formatting changes usually leads to merge conflicts. It is better to handle it in a separate PR next time |
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.
LGTM apart from the code formatting
I have solved most of the formatting issues. Thanks for the review. Think, that it is ready for merge. Suggest changes if needed. @oleg-nenashev @runzexia |
my attempt to fix the issue(55803,Performance: Replace RoleMap#getRolesHavingPermission() usages by iterators) by removing the intermediate collections each time the method is invoked. i did so by implementing the logic of the for loop in the roleWalker() itself. I removed the now not used method getRolesHavingPermission().