-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LANG-1720: Fix Javadoc description of exceptions thrown for existing classes #1160
Conversation
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not api doc. It's a new exception, and I'm not sure it's correct.
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should maybe be IndexOutOfBoundsException
@@ -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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Hm, where are we on this PR? |
During my usage of commons-lang, I have noticed some exceptions (in
StringUtils
,StrSubstitutor
,CharSequenceTranslator
andConversion
) that are not documented in the Javadoc, which I consider to be unhandled exceptions.Before creating my this PR, I noticed #1139, which addresses similar issues. In order to avoid conflicts and show my respect, I have removed some of the Javadoc comments I added in
Conversion.java
, aligning with PR #1139.