如果我直接使用我的助焊剂与StepVerifier
工作正常,但如果我在助焊剂上调用publish().autoConnect()
并使用StepVerifier
的结果,那么verify()
步骤永远不会完成。
例如。我有一个像这样的简单通量,生成0到无穷大的整数:
Flux<Integer> flux = Flux.fromStream(Stream.iterate(0, i -> i + 1));
然后一切正常与StepVerifier
如果我只消耗一些元素,取消并验证:
StepVerifier.create(flux)
.thenConsumeWhile(i -> i < 10)
.thenCancel()
.verify();
但如果相反,我会做以下事情然后它永远不会完成:
StepVerifier.create(flux.publish().autoConnect())
.thenConsumeWhile(i -> i < 10)
.thenCancel()
.verify();
我猜这里有一些相当明显的东西,但我不知道是什么?
当我试图在一个看起来像这样的API的测试中使用StepVerifier
时,这就出现了:
class MyApi {
private Flux<Integer> underlyingFlux = ...
Flux<Integer> getFlux() { return underlyingFlux.publish().autoConnect(); }
}
请参阅我的github examples一些准备运行的代码,该代码演示了我在StepVerifier
上看到的问题。
更新:此问题被Reactor团队接受为错误 - 请参阅问题#1528 - 并且版本3.2.9.RELEASE of reactor-core中提供了修复程序。
这个问题被Reactor团队认为是一个bug - 请参阅#1528问题 - 并且版本3.2.9.RELEASE of reactor-core中提供了一个修复程序。