Open
Description
Describe the bug
The two reactive batch loaders that take a context object throw a class cast exception if used.
The reason this is happening is that these methods missed the specific XXXContext methods and hence it falls through them and tries to cast them to BatchLoader
private boolean isPublisher() {
return batchLoadFunction instanceof BatchPublisher;
}
private boolean isMappedPublisher() {
return batchLoadFunction instanceof MappedBatchPublisher;
}
it should be
private boolean isMappedPublisher() {
return batchLoadFunction instanceof MappedBatchPublisher || batchLoadFunction instanceof MappedBatchPublisherWithContext;
}
**To Reproduce**
Kotlin example below but the same would happen in Java
val batchLoadFunction = MappedBatchPublisherWithContext<String, String?>
{ keys, subscriber, env ->
val map: Map<String, String?> = keys.associateBy({ it })
Flux.fromIterable(map.entries).subscribe(subscriber);
}
val dataLoader: DataLoader<String, String?> = DataLoaderFactory.newMappedPublisherDataLoader(batchLoadFunction)
val cfA = dataLoader.load("A")
val cfB = dataLoader.load("B")
dataLoader.dispatch()
assert(cfA.join().equals("A"))
assert(cfB.join().equals("B"))
Metadata
Metadata
Assignees
Labels
No labels