AmarGhugare opened a new pull request, #1875:
URL: https://github.com/apache/commons-lang/pull/1875
`StringUtils.abbreviate("abcdefghijklmno", Integer.MIN_VALUE, 10)` returns
`...ijklmno` instead of `abcdefg...`. Negative offsets already select the
beginning in the documented examples, but the length-minus-offset subtraction
overflows for sufficiently negative values and incorrectly selects the tail
branch.
Perform that subtraction in `long` arithmetic. The existing comparison and
abbreviation behavior are preserved without adding an API. Regression tests
cover both offset overloads, values on either side of the overflow boundary,
ordinary negative/zero offsets, and custom/empty/null markers. Six cases fail
without the fix.
Validation: `mvn -o -B -ntp` passed on JDK 25.0.4.1: 119,340 tests run, zero
failures/errors, and 18 skipped. Coverage, license checks, Checkstyle, binary
compatibility, SpotBugs, PMD, and Javadoc checks passed.
Jira filing is pending approval of the Apache Jira account. The reproduction
and proposed fix are included here for review in the meantime.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]