static Map < Method , Method > toFallbackMethod ( Map < Method , MethodHandler > dispatch ) { Map < Method , Method > result = new LinkedHashMap < Method , Method > ( ) ; for ( Method method : dispatch . keySet ( ) ) { method . setAccessible ( true ) ; result . put ( method , method ) ; } return result ; }
If the method param of InvocationHandler . invoke is not accessible i . e in a package - private interface the fallback call in hystrix command will fail cause of access restrictions . But methods in dispatch are copied methods . So setting access to dispatch method doesn t take effect to the method in InvocationHandler . invoke . Use map to store a copy of method to invoke the fallback to bypass this and reducing the count of reflection calls .