Skip to content

Conversation

arturobernalg
Copy link
Member

…eption.

When a reactor dependency cycle is detected, wrap the underlying org.codehaus.plexus.util.dag.CycleDetectedException in a new ProjectCycleException and throw a checked ProjectBuildingException (as declared by ProjectBuilder) instead of a raw RuntimeException.

Keep non-cycle model problems on the existing ProjectBuildingException(results) path.

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

  • [X ] Your pull request should address just one issue, without pulling in other changes.
  • [X ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • [X ] 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.
  • [X ] Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • [ X] 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.

@arturobernalg arturobernalg changed the title Replace raw RuntimeException on reactor cycle with ProjectBuildingExc… Fix #10950: Replace raw RuntimeException on reactor cycle with ProjectBuildingExc… Sep 3, 2025
final ProjectCycleException pce = new ProjectCycleException(
"The projects in the reactor contain a cyclic reference: " + cycle.getMessage(), cde);

// If you can resolve these from the problem/result, set them; otherwise leave null.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment doesn't seem right. They can't be set here.

"The projects in the reactor contain a cyclic reference: " + cycle.getMessage(),
(CycleDetectedException) cycle.getException()));
pomFile,
pce);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not clear why pce was created. Could you just pass the cde here?

…; keep CycleDetectedException as cause.

Non-cycle model problems still use ProjectBuildingException(results).
Remove misleading comment about projectId/pomFile.
@arturobernalg
Copy link
Member Author

please do another pass

@gnodet gnodet added bug Something isn't working backport labels Sep 4, 2025
@@ -492,10 +491,14 @@ List<ProjectBuildingResult> build(List<File> pomFiles, boolean recursive) throws
.findAny()
.orElse(null);
if (cycle != null) {
throw new RuntimeException(new ProjectCycleException(
final CycleDetectedException cde = (CycleDetectedException) cycle.getException();
Copy link
Contributor

Choose a reason for hiding this comment

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

The wrapping still smells like something's not quite right. The code is quite complex, and it might be simpler without the lambda, but either way we really should be able to just throw the CycleDetectedException. This is not a public method so we can easily add that to the method signature. It's also possible CycleDetectedException should be a subclass of ProjectBuildingException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants