diff --git a/spring-cloud-netflix-core/pom.xml b/spring-cloud-netflix-core/pom.xml
index e269c330..9142c4a7 100644
--- a/spring-cloud-netflix-core/pom.xml
+++ b/spring-cloud-netflix-core/pom.xml
@@ -44,6 +44,11 @@
reactor-core
true
+
+ io.projectreactor
+ reactor-test
+ test
+
io.reactivex
rxjava-reactive-streams
diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixCommands.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixCommands.java
index 1aceeeef..c6e1611b 100644
--- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixCommands.java
+++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixCommands.java
@@ -104,7 +104,7 @@ public class HystrixCommands {
if (this.eager) {
observable = command.observe();
} else {
- observable = command.toObservable();
+ observable = command.toObservable().onBackpressureBuffer();
}
return RxReactiveStreams.toPublisher(observable);
}
diff --git a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixCommandsTests.java b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixCommandsTests.java
index 17063e99..06c09a13 100644
--- a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixCommandsTests.java
+++ b/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixCommandsTests.java
@@ -16,18 +16,19 @@
package org.springframework.cloud.netflix.hystrix;
+import java.time.Duration;
import java.util.List;
+import com.netflix.hystrix.exception.HystrixRuntimeException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-
-import com.netflix.hystrix.exception.HystrixRuntimeException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
+import reactor.test.StepVerifier;
+
+import static org.assertj.core.api.Assertions.assertThat;
public class HystrixCommandsTests {
@@ -75,6 +76,18 @@ public class HystrixCommandsTests {
assertThat(list).hasSize(2).contains("1", "2");
}
+ @Test
+ public void fluxWorksDeferredRequest() {
+ StepVerifier.create(HystrixCommands.from(Flux.just("1", "2"))
+ .commandName("multiflux")
+ .build(), 1)
+ .expectNext("1")
+ .thenAwait(Duration.ofSeconds(1))
+ .thenRequest(1)
+ .expectNext("2")
+ .verifyComplete();
+ }
+
@Test
public void eagerFluxWorks() {
List list = HystrixCommands.from( Flux.just("1", "2"))