Skip to content

Commit

Permalink
Improved implementation, fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Feb 6, 2016
1 parent f8da6aa commit 5846092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import rx.Observable;

import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestContext;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableDefault;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableHolder;
import com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableLifecycle;
Expand Down Expand Up @@ -100,6 +101,9 @@ private static HystrixRequestCache getInstance(RequestCacheKey rcKey, HystrixCon
/* package */<T> Observable<T> get(String cacheKey) {
ValueCacheKey key = getRequestCacheKey(cacheKey);
if (key != null) {
if (!HystrixRequestContext.isCurrentThreadInitialized()) {
throw new IllegalStateException("Failed to get HystrixRequestVariable. Maybe you need to initialize the HystrixRequestContext?");
}
/* look for the stored value */
return (Observable<T>) requestVariableForCache.get(concurrencyStrategy).get(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public T get(HystrixConcurrencyStrategy concurrencyStrategy) {
}
}

T result = (T) requestVariableInstance.get(key).get();
if (result == null) {
throw new IllegalStateException("Failed to get HystrixRequestVariable. Maybe you need to initialize the HystrixRequestContext?");
}
return result;
return (T) requestVariableInstance.get(key).get();
}

private static class RVCacheKey {
Expand Down

0 comments on commit 5846092

Please sign in to comment.