Copy input arrays when constructing chunks by parijat1222q · Pull Request #243 · java-diff-utils/java-diff-utils
Repository navigation
Copy input arrays when constructing chunks - #243
Open
parijat1222q wants to merge 1 commit into java-diff-utils:master from parijat1222q:fix/chunk-array-copy
Open
Copy input arrays when constructing chunks #243 parijat1222q wants to merge 1 commit into java-diff-utils:master from parijat1222q:fix/chunk-array-copy
Conversation
parijat1222q commented Nov 10, 2026
Copy link Copy Markdown
Fixes #242 .
The array constructors promise a copy, but Arrays.asList(lines) keeps the caller's array. Mutating a source array can make a previously constructed patch fail verification; mutating a revised array silently changes its output.
Copy the array-backed list into an ArrayList, matching the existing List overload. The two-argument array overload delegates to this constructor, so both paths are covered by the one-line fix. No change to the separate mutable getLines/setLines API.
Three regressions exercise patch application after source/revised array changes and the overload with change positions. All three fail on the unchanged implementation: two source-verification errors and one wrong-output assertion.
Validation on Linux, Temurin 17.0.21:
mvn -B -ntp packagepasses across both modules.- 173 tests, zero failures/errors, 3 existing skipped tests.
- Zero Checkstyle violations; Javadocs built.
- The formatter's existing JDK21 incompatibility was avoided by using JDK17, which is in the repository's CI matrix. No build or test checks were disabled.
Copy input arrays when constructing chunks
cdbaab1
Keep saved patch lines independent of the caller's array, matching the List constructors and the documented copy semantics. Add regressions for source and revised array changes through both constructor paths. Fixes java-diff-utils#242
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment