How to test if a Publisher is a cached one in reactor spring?

Viewed 138

I have two publishers:

val text = Mono.just("demo")

val cachedText = Mono.just("demo").cache()

How can I test check if one is cached and the other isn't?

I know that the cached one is of type "reactor.core.publisher.MonoCacheTime" but this type is internal. I see no chance to test against that?

Any ideas?

Thanks

1 Answers

if you're sure this is an "either the Mono is cached with a specific configuration or it isn't cached" situation, you could try to see what the Scannable.from(mono).stepName() returns, but that is only marginally better than relying on the class name.

Related