Skip to content

Commit 46cc7b0

Browse files
author
Matt Jacobs
committed
Only check the property value of isRequestCacheEnabled() once in HystrixObservableCollapser
1 parent a8b064d commit 46cc7b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hystrix-core/src/main/java/com/netflix/hystrix/HystrixObservableCollapser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ public Observable<ResponseType> toObservable() {
410410
*/
411411
public Observable<ResponseType> toObservable(Scheduler observeOn) {
412412

413+
final boolean isRequestCacheEnabled = getProperties().requestCacheEnabled().get();
414+
413415
/* try from cache first */
414-
if (getProperties().requestCacheEnabled().get()) {
416+
if (isRequestCacheEnabled) {
415417
Observable<ResponseType> fromCache = requestCache.get(getCacheKey());
416418
if (fromCache != null) {
417419
metrics.markResponseFromCache();
@@ -422,7 +424,7 @@ public Observable<ResponseType> toObservable(Scheduler observeOn) {
422424
RequestCollapser<BatchReturnType, ResponseType, RequestArgumentType> requestCollapser = collapserFactory.getRequestCollapser(collapserInstanceWrapper);
423425
Observable<ResponseType> response = requestCollapser.submitRequest(getRequestArgument());
424426
metrics.markRequestBatched();
425-
if (getProperties().requestCacheEnabled().get()) {
427+
if (isRequestCacheEnabled) {
426428
/*
427429
* A race can occur here with multiple threads queuing but only one will be cached.
428430
* This means we can have some duplication of requests in a thread-race but we're okay

0 commit comments

Comments
 (0)