Skip to content

Commit 0af69af

Browse files
committed
Remove unused
org.apache.commons.beanutils2.MethodUtils.invokeExactMethod(Object, String, Object)
1 parent 7112a54 commit 0af69af

File tree

3 files changed

+1
-59
lines changed

3 files changed

+1
-59
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0 #357.</action>
3939
<!-- REMOVE -->
4040
<action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused ConstructorUtils in favor of Apache Commons Lang's ConstructorUtils. ConstructorUtils is unused in this component.</action>
41-
41+
<action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused org.apache.commons.beanutils2.MethodUtils.invokeExactMethod(Object, String, Object) in favor of Apache Commons Lang's MethodUtils.</action>
4242
</release>
4343
<release version="2.0.0-M2" date="2025-05-25" description="This is a major release and requires Java 8.">
4444
<!-- FIX -->

src/main/java/org/apache/commons/beanutils2/MethodUtils.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -614,29 +614,6 @@ private static float getTotalTransformationCost(final Class<?>[] srcArgs, final
614614
return totalCost;
615615
}
616616

617-
/**
618-
* <p>
619-
* Invoke a method whose parameter type matches exactly the object type.
620-
* </p>
621-
*
622-
* <p>
623-
* This is a convenient wrapper for {@link #invokeExactMethod(Object object,String methodName,Object [] args)}.
624-
* </p>
625-
*
626-
* @param object invoke method on this object
627-
* @param methodName get method with this name
628-
* @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
629-
* @return The value returned by the invoked method
630-
* @throws NoSuchMethodException if there is no such accessible method
631-
* @throws InvocationTargetException wraps an exception thrown by the method invoked
632-
* @throws IllegalAccessException if the requested method is not accessible via reflection
633-
*/
634-
public static Object invokeExactMethod(final Object object, final String methodName, final Object arg)
635-
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
636-
final Object[] args = toArray(arg);
637-
return invokeExactMethod(object, methodName, args);
638-
}
639-
640617
/**
641618
* <p>
642619
* Invoke a method whose parameter types match exactly the object types.

src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import static org.junit.jupiter.api.Assertions.assertEquals;
2020
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2121
import static org.junit.jupiter.api.Assertions.assertNotNull;
22-
import static org.junit.jupiter.api.Assertions.assertNull;
2322
import static org.junit.jupiter.api.Assertions.assertThrows;
2423
import static org.junit.jupiter.api.Assertions.assertTrue;
2524

@@ -101,40 +100,6 @@ void testGetAccessibleMethodIndirectInterface() {
101100
assertMethod(method, "methodBaz");
102101
}
103102

104-
/**
105-
* <p>
106-
* Test {@code invokeExactMethod}.
107-
*/
108-
@Test
109-
void testInvokeExactMethod() throws Exception {
110-
final TestBean bean = new TestBean();
111-
final Object ret = MethodUtils.invokeExactMethod(bean, "setStringProperty", "TEST");
112-
113-
assertNull(ret);
114-
assertEquals("TEST", bean.getStringProperty(), "Method ONE was invoked");
115-
}
116-
117-
@Test
118-
void testInvokeExactMethodFromInterface() throws Exception {
119-
final Object ret = MethodUtils.invokeExactMethod(PrivateBeanFactory.create(), "methodBar", "ANOTHER TEST");
120-
121-
assertEquals("ANOTHER TEST", ret, "Method TWO wasn't invoked correctly");
122-
}
123-
124-
@Test
125-
void testInvokeExactMethodIndirectInterface() throws Exception {
126-
final Object ret = MethodUtils.invokeExactMethod(PrivateBeanFactory.createSubclass(), "methodBaz", "YET ANOTHER TEST");
127-
128-
assertEquals("YET ANOTHER TEST", ret, "Method TWO was invoked correctly");
129-
}
130-
131-
@Test
132-
void testInvokeExactMethodNull() throws Exception {
133-
final Object object = new Object();
134-
final Object result = MethodUtils.invokeExactMethod(object, "toString", (Object) null);
135-
assertEquals(object.toString(), result);
136-
}
137-
138103
@Test
139104
void testInvokeExactMethodNullArray() throws Exception {
140105
final Object result = MethodUtils.invokeExactMethod(new AlphaBean("parent"), "getName", null);

0 commit comments

Comments
 (0)