Be more robust against load callback failures

Issue: #2795

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=174836960
This commit is contained in:
olly 2017-11-07 04:30:48 -08:00 committed by Oliver Woodman
parent f014b67d3e
commit 7f135f2cda

View File

@ -380,7 +380,13 @@ public final class Loader implements LoaderErrorThrower {
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 final class Loader implements LoaderErrorThrower {
start(getRetryDelayMillis());
}
break;
default:
// Never happens.
break;
}
}