Skip to content

Commit

Permalink
Merge pull request #912 from mattrjacobs/only-check-cache-enabled-onc…
Browse files Browse the repository at this point in the history
…e-observable-collapser

Only check the property value of isRequestCacheEnabled() once in HystrixObservableCollapser
  • Loading branch information
mattrjacobs committed Sep 27, 2015
2 parents 29518d6 + 46cc7b0 commit dfdecf5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ public Observable<ResponseType> toObservable() {
*/
public Observable<ResponseType> toObservable(Scheduler observeOn) {

final boolean isRequestCacheEnabled = getProperties().requestCacheEnabled().get();

/* try from cache first */
if (getProperties().requestCacheEnabled().get()) {
if (isRequestCacheEnabled) {
Observable<ResponseType> fromCache = requestCache.get(getCacheKey());
if (fromCache != null) {
metrics.markResponseFromCache();
Expand All @@ -422,7 +424,7 @@ public Observable<ResponseType> toObservable(Scheduler observeOn) {
RequestCollapser<BatchReturnType, ResponseType, RequestArgumentType> requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper);
Observable<ResponseType> response = requestCollapser.submitRequest(getRequestArgument());
metrics.markRequestBatched();
if (getProperties().requestCacheEnabled().get()) {
if (isRequestCacheEnabled) {
/*
* A race can occur here with multiple threads queuing but only one will be cached.
* This means we can have some duplication of requests in a thread-race but we're okay
Expand Down

0 comments on commit dfdecf5

Please sign in to comment.