Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/lang3/ClassUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public static Class<?> getClass(final ClassLoader classLoader, final String clas
}
}
} while (lastDotIndex != -1);
throw new ClassNotFoundException(next);
throw new ClassNotFoundException(className);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ private void assertGetClassThrowsClassNotFound(final String className) {
}

private void assertGetClassThrowsException(final String className, final Class<? extends Exception> exceptionType) {
assertThrows(exceptionType, () -> ClassUtils.getClass(className),
final Exception exception = assertThrows(exceptionType, () -> ClassUtils.getClass(className),
"ClassUtils.getClass() should fail with an exception of type " + exceptionType.getName() + " when given class name \"" + className + "\".");
if (className != null) {
assertEquals(className, exception.getMessage());
}
}

private void assertGetClassThrowsNullPointerException(final String className) {
Expand Down Expand Up @@ -1251,6 +1254,7 @@ void testGetClassClassNotFound() throws Exception {
assertGetClassThrowsClassNotFound("bool");
assertGetClassThrowsClassNotFound("bool[]");
assertGetClassThrowsClassNotFound("integer[]");
assertGetClassThrowsClassNotFound("org.apache.commons.lang3.ClassUtilsTest.AClassThatCannotBeFound");
}

@Test
Expand Down
Loading