diff --git a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/CacheInvocationContextFactory.java b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/CacheInvocationContextFactory.java index f4fa07297..59d4d42b7 100644 --- a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/CacheInvocationContextFactory.java +++ b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/cache/CacheInvocationContextFactory.java @@ -40,8 +40,8 @@ public class CacheInvocationContextFactory { * @return initialized and configured {@link CacheInvocationContext} */ public static CacheInvocationContext createCacheResultInvocationContext(MetaHolder metaHolder) { - if (metaHolder.getMethod().isAnnotationPresent(CacheResult.class)) { - Method method = metaHolder.getMethod(); + Method method = metaHolder.getMethod(); + if (method.isAnnotationPresent(CacheResult.class)) { CacheResult cacheResult = method.getAnnotation(CacheResult.class); MethodExecutionAction cacheKeyMethod = createCacheKeyAction(cacheResult.cacheKeyMethod(), metaHolder); return new CacheInvocationContext(cacheResult, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs()); @@ -56,8 +56,8 @@ public static CacheInvocationContext createCacheResultInvocationCon * @return initialized and configured {@link CacheInvocationContext} */ public static CacheInvocationContext createCacheRemoveInvocationContext(MetaHolder metaHolder) { - if (metaHolder.getMethod().isAnnotationPresent(CacheRemove.class)) { - Method method = metaHolder.getMethod(); + Method method = metaHolder.getMethod(); + if (method.isAnnotationPresent(CacheRemove.class)) { CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); MethodExecutionAction cacheKeyMethod = createCacheKeyAction(cacheRemove.cacheKeyMethod(), metaHolder); return new CacheInvocationContext(cacheRemove, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs()); diff --git a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/GenericCommand.java b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/GenericCommand.java index 84fa2a4f2..4cdc0d66a 100644 --- a/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/GenericCommand.java +++ b/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/GenericCommand.java @@ -64,15 +64,15 @@ Object execute() { */ @Override protected Object getFallback() { - if (getFallbackAction() != null) { - final CommandAction commandAction = getFallbackAction(); + final CommandAction commandAction = getFallbackAction(); + if (commandAction != null) { try { return process(new Action() { @Override Object execute() { MetaHolder metaHolder = commandAction.getMetaHolder(); Object[] args = createArgsForFallback(metaHolder, getExecutionException()); - return commandAction.executeWithArgs(commandAction.getMetaHolder().getFallbackExecutionType(), args); + return commandAction.executeWithArgs(metaHolder.getFallbackExecutionType(), args); } }); } catch (Throwable e) { diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEvents.java b/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEvents.java index bcb62ede4..9eb7c6afb 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEvents.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/metric/HystrixRequestEvents.java @@ -61,9 +61,8 @@ public Map> getExecutionsMappedToLatencies() { Map> commandDeduper = new HashMap>(); for (HystrixInvokableInfo execution: nonCachedExecutions) { int cachedCount = 0; - String cacheKey = null; - if (execution.getPublicCacheKey() != null) { - cacheKey = execution.getPublicCacheKey(); + String cacheKey = execution.getPublicCacheKey(); + if (cacheKey != null) { CommandAndCacheKey key = new CommandAndCacheKey(execution.getCommandKey().name(), cacheKey); cachedCount = cachingDetector.get(key); }