You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/01/27 19:44:51 UTC

git commit: Trying an alternative to c49489afc8

Updated Branches:
  refs/heads/JCLOUDS-415 c49489afc -> d24324098


Trying an alternative to c49489afc8


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/d2432409
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/d2432409
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/d2432409

Branch: refs/heads/JCLOUDS-415
Commit: d243240982554a17cc1223717fb783ff4ff3ca62
Parents: c49489a
Author: Andrew Phillips <an...@apache.org>
Authored: Mon Jan 27 13:44:23 2014 -0500
Committer: Andrew Phillips <an...@apache.org>
Committed: Mon Jan 27 13:44:23 2014 -0500

----------------------------------------------------------------------
 .../internal/DelegatesToInvocationFunction.java | 26 ++++----------------
 1 file changed, 5 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/d2432409/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java b/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java
index 8d94c3e..79f6019 100644
--- a/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java
+++ b/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java
@@ -120,18 +120,18 @@ public class DelegatesToInvocationFunction<S, F extends Function<Invocation, Obj
       Invokable<?, Object> invokable = method(ownerType, invoked);
       Invocation invocation = Invocation.create(invokable, args);
       try {
-         return handle(invocation);
+         return handle(invocation, invoked);
       } catch (Throwable e) {
          propagateIfPossible(e, invocation.getInvokable().getExceptionTypes());
          throw e;
       }
    }
 
-   private static final Invokable<?, ?> CLOSE;
+   private static final Method CLOSE;
 
    static {
       try {
-         CLOSE = Invokable.from(Closeable.class.getMethod("close"));
+         CLOSE = Closeable.class.getMethod("close");
       } catch (SecurityException e) {
          throw propagate(e);
       } catch (NoSuchMethodException e) {
@@ -139,9 +139,9 @@ public class DelegatesToInvocationFunction<S, F extends Function<Invocation, Obj
       }
    }
 
-   protected Object handle(Invocation invocation) {
+   protected Object handle(Invocation invocation, Method invoked) {
       Invokable<?, ?> invokable = invocation.getInvokable();
-      if (isCloseMethod(invokable)) {
+      if (CLOSE.equals(invoked)) {
          try {
             injector.getInstance(Closer.class).close();
             return null;
@@ -157,22 +157,6 @@ public class DelegatesToInvocationFunction<S, F extends Function<Invocation, Obj
       }
    }
 
-   private static boolean isCloseMethod(Invokable<?, ?> invokable) {
-      /*
-       * Tests equality according to the Javadoc for java.lang.reflect.Method:
-       *
-       * Two Methods are the same if they were declared by the same class
-       * and have the same name and formal parameter types and return type.
-       *
-       * Invokable now uses the *owning* class (not the declaring class) in
-       * its equals check.
-       */
-      return CLOSE.getDeclaringClass().equals(invokable.getDeclaringClass())
-              && CLOSE.getName().equals(invokable.getName())
-              && CLOSE.getParameters().equals(invokable.getParameters())
-              && CLOSE.getReturnType().equals(invokable.getReturnType());
-   }
-
    protected final Injector injector;
    protected final TypeToken<S> ownerType;
    protected final SetCaller setCaller;