Skip to content

Avoid overwriting parent pom from marker when going in child.#5821

Merged
sambsnyd merged 3 commits intomainfrom
issue-5673
Aug 5, 2025
Merged

Avoid overwriting parent pom from marker when going in child.#5821
sambsnyd merged 3 commits intomainfrom
issue-5673

Conversation

@Jenson3210
Copy link
Copy Markdown
Contributor

@Jenson3210 Jenson3210 commented Jul 29, 2025

Thanks for the helpful reproducers @xLitil

What's changed?

By only putting if absent, the resulting Map now contains the requested pom of the level in the hierarchy and not the deeper nested ones. As we make changes to the pom itself and not to the child's parent references, the update marker was failing to resolve due to a child's requested pom overwriting the parent requested pom.

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Should we rework the code to update all the child's parent references when removing dependency? I think this should suffice as the parents references are update in a later stage to the newly calculated parent. We just had to be able to calculate the parent which was failing.

Now I also wonder if we can ever come in the situation where we do not start from the parent in that marker building that Map as that would then use the nested one and not the parent However, we could easily traverse to the highest parent first before building the map resulting in always the same MAP/pom values to be present iso the entry point where you called the method. Traversing to parent == null first would mean some more loops, but also acceptable imho. That would be more correct.

Anyone you would like to review specifically?

@timtebeek please see comment above and inform me what you think would be best

Related issues

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Jenson3210 Jenson3210 self-assigned this Jul 29, 2025
@Jenson3210 Jenson3210 added the bug Something isn't working label Jul 29, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jul 29, 2025
@openrewrite openrewrite deleted a comment from github-actions bot Jul 29, 2025
@openrewrite openrewrite deleted a comment from github-actions bot Jul 29, 2025
@Jenson3210 Jenson3210 requested a review from timtebeek July 29, 2025 10:51
Comment on lines 234 to 236
if (parent != null) {
parent.getProjectPomsRecursive(projectPoms);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hard to say if there could be any negative impact since we seem to be bubbling up; but from the call log above it seems we'd still visit a parent first. Given how minimal the change is here we can monitor for any effects downstream.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it seems it is written to be able to go all directions and start at any entrypoint.
That's indeed the reason of my asking if we should first bubble up so that at least we always have the same result whatever pom you start from

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jul 29, 2025
@sambsnyd sambsnyd merged commit b9d47bb into main Aug 5, 2025
2 checks passed
@sambsnyd sambsnyd deleted the issue-5673 branch August 5, 2025 20:27
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Aug 5, 2025
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

Archived in project

Development

Successfully merging this pull request may close these issues.

Illegal character in path at index 76: ~/.m2/repository/org/apache/logging/log4j/log4j-bom/${log4j2.version}/log4j-bom-${log4j2.version}.pom

4 participants