Repository: cxf Updated Branches: refs/heads/master c2b70fd46 -> d5585c4c3
[CXF-6438] Optimize ExtensionInvocationHandler Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d5585c4c Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d5585c4c Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d5585c4c Branch: refs/heads/master Commit: d5585c4c352803bfdf43e91d3c5dd2bea2abeb86 Parents: c2b70fd Author: Alessio Soldano <asold...@redhat.com> Authored: Thu Jun 4 16:07:25 2015 +0200 Committer: Alessio Soldano <asold...@redhat.com> Committed: Thu Jun 4 16:07:25 2015 +0200 ---------------------------------------------------------------------- .../cxf/common/util/ExtensionInvocationHandler.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/d5585c4c/core/src/main/java/org/apache/cxf/common/util/ExtensionInvocationHandler.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/common/util/ExtensionInvocationHandler.java b/core/src/main/java/org/apache/cxf/common/util/ExtensionInvocationHandler.java index 1524c18..7672382 100644 --- a/core/src/main/java/org/apache/cxf/common/util/ExtensionInvocationHandler.java +++ b/core/src/main/java/org/apache/cxf/common/util/ExtensionInvocationHandler.java @@ -30,15 +30,13 @@ public class ExtensionInvocationHandler implements InvocationHandler { } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - Class<?>[] clzs = null; - if (args != null) { - clzs = new Class[args.length]; - for (int i = 0; i < args.length; i++) { - clzs[i] = args[i].getClass(); - } + if (method.getDeclaringClass().isAssignableFrom(obj.getClass())) { + return method.invoke(obj, args); + } else { + //in case obj has the required method with exact signature despite it's class + //not being assignable from the class declaring the specified method + Method m = obj.getClass().getMethod(method.getName(), method.getParameterTypes()); + return m.invoke(obj, args); } - - Method m = obj.getClass().getMethod(method.getName(), method.getParameterTypes()); - return m.invoke(obj, args); } }