From 787ab8c3b87559d4cf6e18dc7bec56f3ef0c79ce Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Tue, 26 Jan 2021 17:08:43 +0100 Subject: [PATCH] Be more robust to publish errors --- .../apollo/internal/RealApolloStore.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java b/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java index 687e3acdb7..df7b354489 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java +++ b/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java @@ -113,8 +113,18 @@ public RealApolloStore(@NotNull NormalizedCache normalizedCache, @NotNull CacheK iterableSubscribers = new LinkedHashSet<>(subscribers); } + RuntimeException firstException = null; for (RecordChangeSubscriber subscriber : iterableSubscribers) { - subscriber.onCacheRecordsChanged(changedKeys); + try { + subscriber.onCacheRecordsChanged(changedKeys); + } catch (RuntimeException e) { + if (firstException == null) { + firstException = e; + } + } + } + if (firstException != null) { + throw firstException; } }