Skip to content
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

Closed
wants to merge 5 commits into from
Closed

LANG-1720: Fix Javadoc description of exceptions thrown for existing classes #1160

wants to merge 5 commits into from

Conversation

LLM4IG
Copy link

@LLM4IG LLM4IG commented Jan 16, 2024

During my usage of commons-lang, I have noticed some exceptions (in StringUtils, StrSubstitutor, CharSequenceTranslator and Conversion) 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.

@@ -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);
Copy link
Contributor

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}
Copy link
Contributor

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}
Copy link
Contributor

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}
Copy link
Contributor

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.

@garydgregory
Copy link
Member

Hm, where are we on this PR?

@LLM4IG LLM4IG closed this by deleting the head repository Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants