Adopt upstream XML trailing-comment formatting - #1180
Merged
Conversation
openrewrite/rewrite#8353 made XML auto-format keep a comment on the same line as the element it trails, instead of reflowing it onto its own line. `AddMockitoJavaAgentToMavenSurefirePlugin` relied on that reflow: when its `<argLine>` is appended into an existing `<configuration>`, the accompanying `<!--suppress MavenModelInspection -->` is no longer the first content of the tag, so it stayed glued to the preceding sibling and read as annotating that element rather than the `<argLine>` below it. Seed the comment with a newline prefix so auto-format keeps it on its own line either way. `JpaCachePropertiesTest` expectations reflowed comments that the input had placed on the same line; they now assert the input's own placement.
Restores the pre-existing expectations, which assert that auto-format moves a trailing comment onto its own line. All 20 cases fail against the current rewrite snapshot: openrewrite/rewrite#8353 now keeps such comments on the line of the element they trail. Leaving the expectations as the desired behaviour rather than absorbing the new output into the test. Red until the formatting is addressed.
openrewrite/rewrite#8355 taught `RemoveContentVisitor` to hand a removed element's prefix to a comment that trailed it, so the comment keeps its own line instead of collapsing onto the preceding sibling. `JpaCacheProperties` removed via `filterTagChildren`, which drops content outright and so never saw that fix; switching the two single-element removals over picks it up and restores the original expectations for 13 of the 20 cases. The remaining 7 remove nothing: the element the comment trails is retained (or merely has an attribute updated), so #8353 now faithfully reproduces the inline placement the input used. Those expectations were asserting the old reflow and are updated to match the source.
timtebeek
marked this pull request as ready for review
July 30, 2026 19:06
mergify Bot
added a commit
to robfrank/linklift
that referenced
this pull request
Aug 20, 2026
…41.0 to 3.42.0 [skip ci] Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 3.41.0 to 3.42.0. Release notes *Sourced from [org.openrewrite.recipe:rewrite-migrate-java's releases](https://github.com/openrewrite/rewrite-migrate-java/releases).* > 3.42.0 > ------ > > What's Changed > -------------- > > * Adopt upstream XML trailing-comment formatting by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1180](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1180) > * Add mapping for CheckForNull to JSpecify annotation by [`@zbynek`](https://github.com/zbynek) in [openrewrite/rewrite-migrate-java#1179](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1179) > * Skip `UseSetOf`/`UseListOf` for `HashSet`/`ArrayList` subclasses by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1182](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1182) > * Avoid hardcoded patch version in UpdateSdkManTest by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1183](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1183) > * Only add the Mockito surefire agent configuration when asked, and keep it minimal by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1184](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1184) > * Make subpackage recursion explicit in the Jackson JAX-RS JSON rename by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1185](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1185) > * Add the Mockito agent properties goal in its own execution by [`@MBoegers`](https://github.com/MBoegers) in [openrewrite/rewrite-migrate-java#1186](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1186) > * Derive SDKMAN test versions from the candidate list by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1188](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1188) > * Do not apply `var` when the generic return type needs the declared type by [`@jevanlingen`](https://github.com/jevanlingen) in [openrewrite/rewrite-migrate-java#1187](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1187) > * Cover legacy Bouncy Castle artifacts and their API changes by [`@timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#1189](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1189) > * Add jakarta.validation-api dependency when migrating com.sun.istack.NotNull by [`@steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-migrate-java#1190](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1190) > > New Contributors > ---------------- > > * [`@zbynek`](https://github.com/zbynek) made their first contribution in [openrewrite/rewrite-migrate-java#1179](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/1179) > > **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.41.0...v3.42.0> Commits * [`1238ceb`](openrewrite/rewrite-migrate-java@1238ceb) OpenRewrite recipe best practices * [`01d0fe8`](openrewrite/rewrite-migrate-java@01d0fe8) Add `jakarta.validation-api` dependency when migrating `com.sun.istack.NotNul... * [`33354b5`](openrewrite/rewrite-migrate-java@33354b5) Cover legacy Bouncy Castle artifacts and their API changes ([#1189](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/1189)) * [`6c648a5`](openrewrite/rewrite-migrate-java@6c648a5) Update Gradle wrapper to 9.7.0 * [`7099ad3`](openrewrite/rewrite-migrate-java@7099ad3) Do not apply `var` when the generic return type needs the declared type ([#1187](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/1187)) * [`ccfa7b0`](openrewrite/rewrite-migrate-java@ccfa7b0) Derive SDKMAN test versions from the candidate list ([#1188](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/1188)) * [`96e8647`](openrewrite/rewrite-migrate-java@96e8647) [Auto] SDKMAN! Java candidates as of 2026-08-10T1102 * [`26f898e`](openrewrite/rewrite-migrate-java@26f898e) Add the Mockito agent properties goal in its own execution ([#1186](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/1186)) * [`d82dd47`](openrewrite/rewrite-migrate-java@d82dd47) OpenRewrite recipe best practices * [`55f2e93`](openrewrite/rewrite-migrate-java@55f2e93) Make subpackage recursion explicit in the Jackson JAX-RS JSON rename ([#1185](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/1185)) * Additional commits viewable in [compare view](openrewrite/rewrite-migrate-java@v3.41.0...v3.42.0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
mainbuild failure in https://github.com/openrewrite/rewrite-migrate-java/actions/runs/30564092748 (22 tests across two classes).Depends on openrewrite/rewrite#8355, now merged and published to
8.89.0-SNAPSHOT.Cause
openrewrite/rewrite#8353 made XML auto-format keep a comment on the same line as the element it trails, instead of reflowing it onto its own line. Both failing test classes relied on that reflow.
AddMockitoJavaAgentToMavenSurefirePluginThe recipe builds
<configuration><!--suppress MavenModelInspection --><argLine>…</argLine></configuration>. Where there is no existing<configuration>the comment is the first content of its tag and still reflows, so those cases never failed. Where the<argLine>is appended into an existing<configuration>, the comment is no longer first content and stayed glued to the preceding sibling:which reads as suppressing an inspection on
<systemPropertyVariables>rather than on the<argLine>it is meant for. Seeding the comment with a newline prefix keeps it on its own line in both paths.JpaCachePropertiesThe 20 failures here split in two, and only the first half is a formatting bug.
13 cases — comment orphaned by removal. The recipe deletes a
<property/>that had a trailing comment; the deleted element's prefix carried the line break, so the comment had none left and collapsed onto the previous line:openrewrite/rewrite#8355 fixed exactly this — but in
RemoveContentVisitor, whereas this recipe removed viafilterTagChildren, which drops content outright and never saw the fix. Both call sites remove a single known element, soRemoveContentVisitoris the natural fit; switching them over restores the original expectations for these 13 with no test changes.7 cases — nothing removed. Here the element the comment trails is retained (
<!-- leave -->,<!-- leave - manual fix -->) or merely has an attribute updated (UNSPECIFIED→NONE), and in two cases the comments were never attached to a removed element at all (<!-- flag --> <!-- add shared-cache-mode … -->). #8353 now reproduces the inline placement the input used:These expectations were asserting the old reflow, so they are updated to match the source. No behavioural change is warranted — the recipe never intended to relocate these comments.
Verification
./gradlew testgreen locally against the post-#8355 snapshot.