From 7f135f2cda7c4108bcb105a7dfad12e1c13a307d Mon Sep 17 00:00:00 2001 From: olly Date: Tue, 7 Nov 2017 04:30:48 -0800 Subject: [PATCH] Be more robust against load callback failures Issue: #2795 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=174836960 --- .../google/android/exoplayer2/upstream/Loader.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java index bd701505736..9e495f42bf5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java @@ -380,7 +380,13 @@ public void handleMessage(Message msg) { callback.onLoadCanceled(loadable, nowMs, durationMs, false); break; case MSG_END_OF_SOURCE: - callback.onLoadCompleted(loadable, nowMs, durationMs); + try { + callback.onLoadCompleted(loadable, nowMs, durationMs); + } catch (RuntimeException e) { + // This should never happen, but handle it anyway. + Log.e(TAG, "Unexpected exception handling load completed", e); + fatalError = new UnexpectedLoaderException(e); + } break; case MSG_IO_EXCEPTION: currentError = (IOException) msg.obj; @@ -392,6 +398,9 @@ public void handleMessage(Message msg) { start(getRetryDelayMillis()); } break; + default: + // Never happens. + break; } }