-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Reactive Streams
-
None
Summary
BatchCursorFlux uses a lambda to subscribe to batchCursorPublisher without propagating the subscriber context.
How to Reproduce
A tad difficult.
MongoClientSettings settings = MongoClientSettings.builder() .contextProvider((ReactiveContextProvider) subscriber -> { if (subscriber instanceof CoreSubscriber<?> cs) { Map<Object, Object> map = cs.currentContext().stream() .collect(Collectors.toConcurrentMap(Entry::getKey, Entry::getValue)); // map is empty } return … }).build(); // later: MongoCollection<Document> reproducer = operations.getCollection("foo").block(); Flux.from(reproducer.find()).contextWrite(Context.of("key", "value")).blockLast();
Additional Background
Discovered during context propagation testing for observability. Other places where lambda-based subscribers are used might be affected, too.