Skip to content

Commit a3132b7

Browse files
Remove handling of Throwable passed into onNext
Passing an exception into `onNext` is not typically done in reactive-land - we would instead call `onError(Throwable)`. We can thus avoid handling this case.
1 parent 68d7f54 commit a3132b7

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/main/java/org/dataloader/DataLoaderHelper.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,7 @@ public void onNext(V value) {
656656
K key = keys.get(idx);
657657
Object callContext = callContexts.get(idx);
658658
CompletableFuture<V> future = queuedFutures.get(idx);
659-
if (value instanceof Throwable) {
660-
stats.incrementLoadErrorCount(new IncrementLoadErrorCountStatisticsContext<>(key, callContext));
661-
future.completeExceptionally((Throwable) value);
662-
clearCacheKeys.add(keys.get(idx));
663-
} else if (value instanceof Try) {
659+
if (value instanceof Try) {
664660
// we allow the batch loader to return a Try so we can better represent a computation
665661
// that might have worked or not.
666662
Try<V> tryValue = (Try<V>) value;
@@ -759,11 +755,7 @@ public void onNext(Map.Entry<K, V> entry) {
759755

760756
Object callContext = callContextByKey.get(key);
761757
CompletableFuture<V> future = queuedFutureByKey.get(key);
762-
if (value instanceof Throwable) {
763-
stats.incrementLoadErrorCount(new IncrementLoadErrorCountStatisticsContext<>(key, callContext));
764-
future.completeExceptionally((Throwable) value);
765-
clearCacheKeys.add(key);
766-
} else if (value instanceof Try) {
758+
if (value instanceof Try) {
767759
// we allow the batch loader to return a Try so we can better represent a computation
768760
// that might have worked or not.
769761
Try<V> tryValue = (Try<V>) value;

0 commit comments

Comments
 (0)