-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Deduplicate filtered dependency graph #2493
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
Deduplicate filtered dependency graph #2493
Conversation
// | ||
// Without de-duplication, the final list would contain E three times, once for E being in the projects and | ||
// whitelisted, and twice more for E being a downstream dependency of B and D. | ||
return filtered.stream().distinct().collect(Collectors.toList()); |
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.
Added and used import of Collectors.toList()
here instead of Stream.toList()
as they have mutability differences.
Stream.toList()
returns an immutable list, akin to Collections.unmodifiableList()
.
Stream.collect(Collectors.toList())
returns a mutable list, akin to ArrayList.addAll()
or Arrays.asList()
.
I'm uncertain whether mutability or immutability is preferred here. So, I went with a straight copy, but if immutability is preferred I'll change this to Stream.toList()
.
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.
FYI @cstamas
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.
if Stream.toList()
can not be used, I would like to add such info also to code.
@alzimmermsft Did you try with immutable list here by executing ITs
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 didn't, I just copied what I had in the other PR.
Will change to Stream.toList()
and test locally. If it passes, I'll use it to match the other stream collections in the file.
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.
@slawekjaranowski switched to Stream.toList()
as the ITs executed without issue.
This is flakey CI, so is +1 |
Port of apache#2489 against master. Fixes apache#2487
Port of #2489 against master.
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verify
to make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.