Commit 6d85e4a
authored
Prevent marker-only changes from producing phantom diffs (#7358)
Dependency-modifying recipes now update JavaSourceSet markers (added in
#7202), which can produce Results with identical before/after text. This
caused downstream test failures in rewrite-dropwizard, rewrite-hibernate,
rewrite-migrate-java, and rewrite-spring.
Three fixes:
1. JavaSourceSet.addTypesForGav returns `this` when the gavKey already
exists with the same types, preventing unnecessary allocations for
LSTs with empty gavToTypes maps.
2. The cached overload of JavaSourceSet.updateOnSourceFile now checks
whether the source file's current marker is already the cached
instance before replacing it, preventing O(n) phantom diffs across
files in the same source set.
3. RewriteTest accepts marker-only changes (identical printed text)
instead of failing with "An empty diff was generated", since these
represent legitimate internal state updates.
Closes #73491 parent 5d04d39 commit 6d85e4a
2 files changed
Lines changed: 17 additions & 1 deletion
File tree
- rewrite-java/src/main/java/org/openrewrite/java/marker
- rewrite-test/src/main/java/org/openrewrite/test
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
181 | 189 | | |
182 | 190 | | |
183 | 191 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
566 | 574 | | |
567 | 575 | | |
568 | 576 | | |
| |||
0 commit comments