aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Gregory <garydgregory@gmail.com>2024-05-24 09:18:12 -0400
committerGary Gregory <garydgregory@gmail.com>2024-05-24 09:18:12 -0400
commitccac05060130f80eed120f5e4801d56f3a1b2ab8 (patch)
tree2d44834d91f99ea71386d310fd0aa2ecbbb86973
parent10306e206eff3d5b421fb88c4a840a62e6fab789 (diff)
downloadapache-commons-lang-ccac05060130f80eed120f5e4801d56f3a1b2ab8.tar.gz
Simplify exception handling
-rw-r--r--src/main/java/org/apache/commons/lang3/ObjectUtils.java12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
index 138d67000..8ca591bd9 100644
--- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java
+++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java
@@ -250,16 +250,8 @@ public class ObjectUtils {
try {
final Method clone = obj.getClass().getMethod("clone");
result = clone.invoke(obj);
- } catch (final NoSuchMethodException e) {
- throw new CloneFailedException("Cloneable type "
- + obj.getClass().getName()
- + " has no clone method", e);
- } catch (final IllegalAccessException e) {
- throw new CloneFailedException("Cannot clone Cloneable type "
- + obj.getClass().getName(), e);
- } catch (final InvocationTargetException e) {
- throw new CloneFailedException("Exception cloning Cloneable type "
- + obj.getClass().getName(), e.getCause());
+ } catch (final ReflectiveOperationException e) {
+ throw new CloneFailedException("Exception cloning Cloneable type " + obj.getClass().getName(), e.getCause());
}
}
return (T) result;