aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2022-07-15 09:19:10 -0400
committerGary Gregory <garydgregory@gmail.com>2022-07-15 09:19:10 -0400
commit78ce2d79f2b1341bfc366b1fde487d960493a08a (patch)
tree2f67e9b34d467d28d478df107d5ab8d4d373cffa /src
parentd6ec3655b12c3b5e96de4570987dd7e64960487c (diff)
downloadapache-commons-lang-78ce2d79f2b1341bfc366b1fde487d960493a08a.tar.gz
More precise exceptions
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java17
-rw-r--r--src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java12
2 files changed, 13 insertions, 16 deletions
diff --git a/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java b/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
index db2ac8fdb..92c371591 100644
--- a/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
+++ b/src/main/java/org/apache/commons/lang3/event/EventListenerSupport.java
@@ -23,6 +23,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
@@ -311,19 +312,19 @@ public class EventListenerSupport<L> implements Serializable {
protected class ProxyInvocationHandler implements InvocationHandler {
/**
- * Propagates the method call to all registered listeners in place of
- * the proxy listener object.
+ * Propagates the method call to all registered listeners in place of the proxy listener object.
*
- * @param unusedProxy the proxy object representing a listener on which the
- * invocation was called; not used
- * @param method the listener method that will be called on all of the
- * listeners.
+ * @param unusedProxy the proxy object representing a listener on which the invocation was called; not used
+ * @param method the listener method that will be called on all of the listeners.
* @param args event arguments to propagate to the listeners.
* @return the result of the method call
- * @throws Throwable if an error occurs
+ * @throws InvocationTargetException if an error occurs
+ * @throws IllegalArgumentException if an error occurs
+ * @throws IllegalAccessException if an error occurs
*/
@Override
- public Object invoke(final Object unusedProxy, final Method method, final Object[] args) throws Throwable {
+ public Object invoke(final Object unusedProxy, final Method method, final Object[] args)
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (final L listener : listeners) {
method.invoke(listener, args);
}
diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
index 70658a746..1b730dc1e 100644
--- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
+++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java
@@ -29,6 +29,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
@@ -174,22 +175,17 @@ public class EventListenerSupportTest extends AbstractLangTest {
@Test
public void testSubclassInvocationHandling() throws PropertyVetoException {
- final
- EventListenerSupport<VetoableChangeListener> eventListenerSupport = new EventListenerSupport<VetoableChangeListener>(
+ final EventListenerSupport<VetoableChangeListener> eventListenerSupport = new EventListenerSupport<VetoableChangeListener>(
VetoableChangeListener.class) {
private static final long serialVersionUID = 1L;
@Override
protected java.lang.reflect.InvocationHandler createInvocationHandler() {
return new ProxyInvocationHandler() {
- /**
- * {@inheritDoc}
- */
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable {
- return "vetoableChange".equals(method.getName())
- && "Hour".equals(((PropertyChangeEvent) args[0]).getPropertyName()) ? null
+ throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ return "vetoableChange".equals(method.getName()) && "Hour".equals(((PropertyChangeEvent) args[0]).getPropertyName()) ? null
: super.invoke(proxy, method, args);
}
};