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.
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.
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.
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.
@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 verifyto 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.