elharo commented on code in PR #1160:
URL: https://github.com/apache/commons-lang/pull/1160#discussion_r1455498553
##########
src/main/java/org/apache/commons/lang3/Conversion.java:
##########
@@ -280,6 +280,9 @@ public static char binaryToHexDigitMsb0_4bits(final
boolean[] src, final int src
if (src.length - srcPos < 4) {
throw new IllegalArgumentException("src.length-srcPos<4:
src.length=" + src.length + ", srcPos=" + srcPos);
}
+ if (srcPos >= 0) {
+ throw new IllegalArgumentException("srcPos>=0: srcPos=" + srcPos);
Review Comment:
This is not api doc. It's a new exception, and I'm not sure it's correct.
##########
src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java:
##########
@@ -538,6 +538,7 @@ public String replace(final char[] source) {
* @param offset the start offset within the array, must be valid
* @param length the length within the array to be processed, must be
valid
* @return the result of the replace operation
+ * @throws StringIndexOutOfBoundsException if {@code offset < 0 || offset
+ length >= source.length}
Review Comment:
Why String instead of array here? If this is the behavior it might be a bug.
Change the doc to just IndexOutOfBoundsException for now in case we need to fix
this.
##########
src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java:
##########
@@ -577,6 +578,7 @@ public String replace(final CharSequence source) {
* @param offset the start offset within the array, must be valid
* @param length the length within the array to be processed, must be
valid
* @return the result of the replace operation
+ * @throws StringIndexOutOfBoundsException if {@code offset < 0 || offset
+ length >= source.length}
Review Comment:
This should maybe be IndexOutOfBoundsException
##########
src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java:
##########
@@ -753,6 +757,7 @@ public boolean replaceIn(final StrBuilder source) {
* @param offset the start offset within the array, must be valid
* @param length the length within the builder to be processed, must be
valid
* @return true if altered
+ * @throws StringIndexOutOfBoundsException if {@code offset < 0 || offset
+ length >= source.length}
Review Comment:
It does strike me as possible that some of these exceptions shouldn't be
thrown at all. If offset or length are out of bounds, maybe nothing is
replaced.
--
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]