joao-jordy opened a new pull request, #1862: URL: https://github.com/apache/commons-lang/pull/1862
`ClassUtils.getPackageName(String)` and `ClassUtils.getShortClassName(String)` threw `StringIndexOutOfBoundsException` for names made up only of `[`, such as `"["` or `"[[["`. - Bound the array-prefix scan by the string length. - Return early when no element type remains: `getPackageName` returns `""`, `getShortClassName` returns the `[]` dimension suffix. - `getShortClassName` also called `substring(1)` once per `[` (O(n^2)). It now counts the prefix once: 200k brackets went from ~930 ms to ~8 ms. Behaviour for valid class names is unchanged. The `IllegalArgumentException` that `getClass`, `getShortCanonicalName` and `getPackageCanonicalName` throw for these inputs is untouched. Tests added to `test_getPackageName_String` and `test_getShortClassName_String`. Full `mvn test` passes (101,892 run, 0 failures, 18 skipped). The checkstyle, PMD, spotbugs, japicmp and rat checks were skipped locally. - [x] Read [CONTRIBUTING.md](https://github.com/apache/commons-lang/blob/master/CONTRIBUTING.md) - [x] Tests added for the changed behaviour 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
