From 2684332d9221a7a7ff963c51488ed51c6093c179 Mon Sep 17 00:00:00 2001 From: Matt Jacobs Date: Wed, 9 Sep 2015 14:52:49 -0700 Subject: [PATCH] RequestBatch can use unsafeSubscribe with an empty Susbcriber instead of paying cost of subscribe() --- .../java/com/netflix/hystrix/collapser/RequestBatch.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java index 622049e80..c422a0ec8 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/collapser/RequestBatch.java @@ -31,6 +31,7 @@ import com.netflix.hystrix.HystrixCollapser; import com.netflix.hystrix.HystrixCollapser.CollapsedRequest; import com.netflix.hystrix.HystrixCollapserProperties; +import rx.observers.Subscribers; /** * A batch of requests collapsed together by a RequestCollapser instance. When full or time has expired it will execute and stop accepting further submissions. @@ -160,14 +161,14 @@ public void call() { Exception e = null; for (CollapsedRequest request : shardRequests) { try { - e = ((CollapsedRequestObservableFunction) request).setExceptionIfResponseNotReceived(e,"No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation."); + e = ((CollapsedRequestObservableFunction) request).setExceptionIfResponseNotReceived(e, "No response set by " + commandCollapser.getCollapserKey().name() + " 'mapResponseToRequests' implementation."); } catch (IllegalStateException e2) { logger.debug("Partial success of 'mapResponseToRequests' resulted in IllegalStateException while setting 'No response set' Exception. Continuing ... ", e2); } } } - }).subscribe(); + }).unsafeSubscribe(Subscribers.empty()); } catch (Exception e) { logger.error("Exception while creating and queueing command with batch.", e);