Skip to content

Commit ad6890f

Browse files
committed
2 parents 4ec9b8e + 94385c8 commit ad6890f

File tree

9 files changed

+132
-146
lines changed

9 files changed

+132
-146
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
5858
# Initializes the CodeQL tools for scanning.
5959
- name: Initialize CodeQL
60-
uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # 3.29.5
60+
uses: github/codeql-action/init@e296a935590eb16afc0c0108289f68c87e2a89a5 # 3.29.5
6161
with:
6262
languages: ${{ matrix.language }}
6363
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -68,7 +68,7 @@ jobs:
6868
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6969
# If this step fails, then you should remove it and run the build manually (see below)
7070
- name: Autobuild
71-
uses: github/codeql-action/autobuild@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # 3.29.5
71+
uses: github/codeql-action/autobuild@e296a935590eb16afc0c0108289f68c87e2a89a5 # 3.29.5
7272

7373
# ℹ️ Command-line programs to run using the OS shell.
7474
# 📚 https://git.io/JvXDl
@@ -82,4 +82,4 @@ jobs:
8282
# make release
8383

8484
- name: Perform CodeQL Analysis
85-
uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # 3.29.5
85+
uses: github/codeql-action/analyze@e296a935590eb16afc0c0108289f68c87e2a89a5 # 3.29.5

.github/workflows/scorecards-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ jobs:
6464
retention-days: 5
6565

6666
- name: "Upload to code-scanning"
67-
uses: github/codeql-action/upload-sarif@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # 3.29.5
67+
uses: github/codeql-action/upload-sarif@e296a935590eb16afc0c0108289f68c87e2a89a5 # 3.29.5
6868
with:
6969
sarif_file: results.sarif

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ site-content
2121

2222
# jenv's version file
2323
.java-version
24+
/.DS_Store

src/changes/changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ The <action> type attribute can be add,update,fix,remove.
5050
<action type="fix" dev="ggregory" due-to="Marcono1234, Gary Gregory">[javadoc] Improve StringUtils Javadoc #1450.</action>
5151
<action type="fix" dev="ggregory" due-to="mayuming, Gary Gregory">Fix internal inverted logic in private isEnum() method and correct its usage in getFirstEnum() #1454.</action>
5252
<action type="fix" dev="ggregory" due-to="William Degrange, Gary Gregory, Rob Spoor">Use accessors in ToStringStyle so subclasses can effectively override them.</action>
53-
<action type="fix" dev="ggregory" due-to="aaaaaa, Gary Gregory">`LocaleUtils.toLocale(String)` for a 2 letter country code now returns a value instead of throwing an `IllegalArgumentException`.</action>
53+
<action type="fix" dev="ggregory" due-to="jack5505, Gary Gregory">`LocaleUtils.toLocale(String)` for a 2 letter country code now returns a value instead of throwing an `IllegalArgumentException`.</action>
54+
<action type="fix" dev="ggregory" due-to="mayuming, Gary Gregory">Fix typo in StringUtils.trunctate() IllegalArgumentException message and test assertion messages.</action>
55+
<action type="fix" dev="ggregory" due-to="mayuming, Gary Gregory">Fix test fixture in ReflectionDiffBuilderTest.testTransientFieldDifference() #1464.</action>
56+
<action issue="LANG-1789" type="fix" dev="ggregory" due-to="Hylke van der Schaaf, Gary Gregory">NullPointerException when generating NoSuchMethodException in MethodUtils.</action>
5457
<!-- ADD -->
5558
<action type="add" dev="ggregory" due-to="Gary Gregory">Add SystemProperties.getPath(String, Supplier&lt;Path&gt;).</action>
5659
<action type="add" dev="ggregory" due-to="Gary Gregory">Add JavaVersion.JAVA_25.</action>

src/main/java/org/apache/commons/lang3/StringUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8866,7 +8866,7 @@ public static String truncate(final String str, final int offset, final int maxW
88668866
throw new IllegalArgumentException("offset cannot be negative");
88678867
}
88688868
if (maxWidth < 0) {
8869-
throw new IllegalArgumentException("maxWith cannot be negative");
8869+
throw new IllegalArgumentException("maxWidth cannot be negative");
88708870
}
88718871
if (str == null) {
88728872
return null;

src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java

Lines changed: 104 additions & 125 deletions
Large diffs are not rendered by default.

src/test/java/org/apache/commons/lang3/StringUtilsTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,16 +2951,16 @@ void testToString() throws UnsupportedEncodingException {
29512951
@Test
29522952
void testTruncate_StringInt() {
29532953
assertNull(StringUtils.truncate(null, 12));
2954-
assertIllegalArgumentException(() -> StringUtils.truncate(null, -1), "maxWith cannot be negative");
2955-
assertIllegalArgumentException(() -> StringUtils.truncate(null, -10), "maxWith cannot be negative");
2956-
assertIllegalArgumentException(() -> StringUtils.truncate(null, Integer.MIN_VALUE), "maxWith cannot be negative");
2954+
assertIllegalArgumentException(() -> StringUtils.truncate(null, -1), "maxWidth cannot be negative");
2955+
assertIllegalArgumentException(() -> StringUtils.truncate(null, -10), "maxWidth cannot be negative");
2956+
assertIllegalArgumentException(() -> StringUtils.truncate(null, Integer.MIN_VALUE), "maxWidth cannot be negative");
29572957
assertEquals("", StringUtils.truncate("", 10));
29582958
assertEquals("abc", StringUtils.truncate("abcdefghij", 3));
29592959
assertEquals("abcdef", StringUtils.truncate("abcdefghij", 6));
29602960
assertEquals("", StringUtils.truncate("abcdefghij", 0));
2961-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -1), "maxWith cannot be negative");
2962-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -100), "maxWith cannot be negative");
2963-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", Integer.MIN_VALUE), "maxWith cannot be negative");
2961+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -1), "maxWidth cannot be negative");
2962+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -100), "maxWidth cannot be negative");
2963+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", Integer.MIN_VALUE), "maxWidth cannot be negative");
29642964
assertEquals("abcdefghij", StringUtils.truncate("abcdefghijklmno", 10));
29652965
assertEquals("abcdefghijklmno", StringUtils.truncate("abcdefghijklmno", Integer.MAX_VALUE));
29662966
assertEquals("abcde", StringUtils.truncate("abcdefghijklmno", 5));
@@ -2979,11 +2979,11 @@ void testTruncate_StringIntInt() {
29792979
assertEquals("abc", StringUtils.truncate("abcdefghij", 0, 3));
29802980
assertEquals("fghij", StringUtils.truncate("abcdefghij", 5, 6));
29812981
assertEquals("", StringUtils.truncate("abcdefghij", 0, 0));
2982-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -1), "maxWith cannot be negative");
2983-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -10), "maxWith cannot be negative");
2984-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -100), "maxWith cannot be negative");
2985-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 1, -100), "maxWith cannot be negative");
2986-
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, Integer.MIN_VALUE), "maxWith cannot be negative");
2982+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -1), "maxWidth cannot be negative");
2983+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -10), "maxWidth cannot be negative");
2984+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, -100), "maxWidth cannot be negative");
2985+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 1, -100), "maxWidth cannot be negative");
2986+
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", 0, Integer.MIN_VALUE), "maxWidth cannot be negative");
29872987
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -1, 0), "offset cannot be negative");
29882988
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -10, 0), "offset cannot be negative");
29892989
assertIllegalArgumentException(() -> StringUtils.truncate("abcdefghij", -100, 1), "offset cannot be negative");

src/test/java/org/apache/commons/lang3/builder/ReflectionDiffBuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import org.apache.commons.lang3.AbstractLangTest;
2626
import org.junit.jupiter.api.Test;
2727

28-
///**
29-
// * Tests {@link ReflectionDiffBuilder}.
30-
// */
28+
/**
29+
* Tests {@link ReflectionDiffBuilder}.
30+
*/
3131
class ReflectionDiffBuilderTest extends AbstractLangTest {
3232

3333
@SuppressWarnings("unused")
@@ -287,7 +287,7 @@ void testTransientFieldDifference() {
287287
final TypeTestClass firstObject = new TypeTestClass();
288288
firstObject.transientField = "a";
289289
final TypeTestClass secondObject = new TypeTestClass();
290-
firstObject.transientField = "b";
290+
secondObject.transientField = "b";
291291
DiffResult<TypeTestClass> list = firstObject.diff(secondObject);
292292
assertEquals(0, list.getNumberOfDiffs());
293293
list = firstObject.diffDeprecated(secondObject);

src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,9 @@ void testInvokeMethod() throws Exception {
11101110
void testInvokeMethod_VarArgsWithNullValues() throws Exception {
11111111
assertEquals("String...", MethodUtils.invokeMethod(testBean, "varOverload", "a", null, "c"));
11121112
assertEquals("String...", MethodUtils.invokeMethod(testBean, "varOverload", "a", "b", null));
1113+
assertEquals("String...", MethodUtils.invokeMethod(testBean, "varOverload", new String[] { "a" }, new Class<?>[] { String.class }));
1114+
assertThrows(NoSuchMethodException.class,
1115+
() -> assertEquals("String...", MethodUtils.invokeMethod(testBean, "doesn't exist", new String[] { "a" }, new Class<?>[] { null })));
11131116
}
11141117

11151118
@Test

0 commit comments

Comments
 (0)