Skip to content

Commit

Permalink
Merge pull request Netflix#1587 from jack-kerouac/patch-1
Browse files Browse the repository at this point in the history
throw IllegalStateException if request cache is not available when clearing
  • Loading branch information
mattrjacobs authored May 31, 2017
2 parents dbc7429 + 45d7875 commit ea14be2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static HystrixRequestCache getInstance(RequestCacheKey rcKey, HystrixCon
/* look for the stored value */
ConcurrentHashMap<ValueCacheKey, HystrixCachedObservable<?>> cacheInstance = requestVariableForCache.get(concurrencyStrategy);
if (cacheInstance == null) {
throw new IllegalStateException("Request caching is not available. Maybe you need to initialize the HystrixRequestContext?");
throw new IllegalStateException("Request caching is not available. Maybe you need to initialize the HystrixRequestContext?");
}
HystrixCachedObservable<T> alreadySet = (HystrixCachedObservable<T>) cacheInstance.putIfAbsent(key, f);
if (alreadySet != null) {
Expand All @@ -150,8 +150,13 @@ private static HystrixRequestCache getInstance(RequestCacheKey rcKey, HystrixCon
public void clear(String cacheKey) {
ValueCacheKey key = getRequestCacheKey(cacheKey);
if (key != null) {
ConcurrentHashMap<ValueCacheKey, HystrixCachedObservable<?>> cacheInstance = requestVariableForCache.get(concurrencyStrategy);
if (cacheInstance == null) {
throw new IllegalStateException("Request caching is not available. Maybe you need to initialize the HystrixRequestContext?");
}

/* remove this cache key */
requestVariableForCache.get(concurrencyStrategy).remove(key);
cacheInstance.remove(key);
}
}

Expand Down

0 comments on commit ea14be2

Please sign in to comment.