NestedPublishers
WARNING
FragileCode
Summary
Avoid
Publisher
s that emit otherPublishers
s; the resultant code is hard to reason about
Suppression
Suppress false positives by adding the suppression annotation
@SuppressWarnings("NestedPublishers")
to the enclosing element.Disable this pattern completely by adding
-Xep:NestedPublishers:OFF
as compiler argument. Learn more.
Samples
Identification
Shows code lines which will (not) be flagged by this bug pattern.
A //BUG: Diagnostic contains:
comment is placed above any violating line.
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.GroupedFlux;
import reactor.core.publisher.Mono;
class A {
void m() {
Mono.empty();
Flux.just(1);
Flux.just(1, 2).groupBy(i -> i).map(groupedFlux -> (GroupedFlux) groupedFlux);
// BUG: Diagnostic contains:
Mono.just(Mono.empty());
// BUG: Diagnostic contains:
Flux.just(Flux.empty());
// BUG: Diagnostic contains:
Mono.just((Flux) Flux.just(1));
// BUG: Diagnostic contains:
Flux.just((Publisher) Mono.just(1));
// BUG: Diagnostic contains:
Mono.just(1).map(Mono::just);
}
}