You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am new to this library. When learning this library, I found that the object type returned by DataLoaderFactory.newDataLoaderWithTry().dispatcher() is inconsistent with the specified generic type.
To Reproduce
The text was updated successfully, but these errors were encountered:
You are right - is is inconsistent when the Try mechanism is used
Data loader is declared as DataLoader<K, V> and hence we get public CompletableFuture<List<V>> dispatch()
The Try wrappers are unwrapped by the engine code and hence the CompletableFuture<V> load(K key) values do come back as the expected V type but the dispatch gives back the raw values and does not unwrap them.
} else if (value instanceof Try) {
// we allow the batch loader to return a Try so we can better represent a computation
// that might have worked or not.
Try<V> tryValue = (Try<V>) value;
if (tryValue.isSuccess()) {
future.complete(tryValue.get());
} else {
stats.incrementLoadErrorCount(new IncrementLoadErrorCountStatisticsContext<>(key, callContext));
future.completeExceptionally(tryValue.getThrowable());
clearCacheKeys.add(keys.get(idx));
}
Perhaps it should unwrap them when giving his back - I would have to think on that more.
The other option would be to have something like DataLoader<K,V,BatchV> where BatchV is the generic type of value coming back from the BatchLoader but thats too viral a change really.
ps. We mostly expect people to use the values via load(k) calls rather than the values coming back via dispatch but you are right its inconsistent.
Describe the bug
I am new to this library. When learning this library, I found that the object type returned by
DataLoaderFactory.newDataLoaderWithTry().dispatcher()
is inconsistent with the specified generic type.To Reproduce
The text was updated successfully, but these errors were encountered: