ppkarwasz commented on code in PR #1644:
URL: https://github.com/apache/commons-lang/pull/1644#discussion_r3254766219
##########
src/main/java/org/apache/commons/lang3/StringUtils.java:
##########
@@ -6117,7 +6117,12 @@ public static String repeat(final String repeat, final
int count) {
if (inputLength == 1 && count <= PAD_LIMIT) {
return repeat(repeat.charAt(0), count);
}
- final int outputLength = inputLength * count;
+ final int outputLength;
+ try {
+ outputLength = Math.multiplyExact(inputLength, count);
+ } catch (final Exception e) {
+ throw new IllegalArgumentException("Count too large for input");
Review Comment:
I believe this is a detail worth discussing. `OutOfMemoryError` might be an
unfortunate choice, so we need to make a compromise between a more fitting
exception and coherence with the JDK. We chose the former, but we did that
choice consciously.
--
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]