Skip to content

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

Merged

Conversation

alzimmermsft
Copy link
Contributor

Port of #2489 against master.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the Core IT successfully.

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.

//
// 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());
Copy link
Contributor Author

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI @cstamas

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@slawekjaranowski slawekjaranowski added the bug Something isn't working label Jun 18, 2025
@cstamas
Copy link
Member

cstamas commented Jun 18, 2025

This is flakey CI, so is +1

@gnodet gnodet self-requested a review June 18, 2025 22:08
@gnodet gnodet added this to the 4.0.0 milestone Jun 18, 2025
@cstamas cstamas merged commit 4e02a89 into apache:master Jun 19, 2025
37 of 38 checks passed
cstamas added a commit to cstamas/maven that referenced this pull request Jun 19, 2025
@alzimmermsft alzimmermsft deleted the DeduplicateFilteredDependencyGraphMaster branch June 19, 2025 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants