Commit 083350b7 by aquilescanta Committed by Oliver Woodman

Do not retry failed loads whose error is FileNotFoundException

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=214277073
parent e86d5efb
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
### dev-v2 (not yet released) ### ### dev-v2 (not yet released) ###
* Do not retry failed loads whose error is `FileNotFoundException`.
* Allow setting log level for ExoPlayer logcat output * Allow setting log level for ExoPlayer logcat output
([#4665](https://github.com/google/ExoPlayer/issues/4665)). ([#4665](https://github.com/google/ExoPlayer/issues/4665)).
* Fix an issue where audio and video would desynchronize when playing * Fix an issue where audio and video would desynchronize when playing
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.upstream;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException; import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
/** Default implementation of {@link LoadErrorHandlingPolicy}. */ /** Default implementation of {@link LoadErrorHandlingPolicy}. */
...@@ -76,13 +77,14 @@ public final class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPo ...@@ -76,13 +77,14 @@ public final class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPo
} }
/** /**
* Retries for any exception that is not a subclass of {@link ParserException}. The retry delay is * Retries for any exception that is not a subclass of {@link ParserException} or {@link
* calculated as {@code Math.min((errorCount - 1) * 1000, 5000)}. * FileNotFoundException}. The retry delay is calculated as {@code Math.min((errorCount - 1) *
* 1000, 5000)}.
*/ */
@Override @Override
public long getRetryDelayMsFor( public long getRetryDelayMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) { int dataType, long loadDurationMs, IOException exception, int errorCount) {
return exception instanceof ParserException return exception instanceof ParserException || exception instanceof FileNotFoundException
? C.TIME_UNSET ? C.TIME_UNSET
: Math.min((errorCount - 1) * 1000, 5000); : Math.min((errorCount - 1) * 1000, 5000);
} }
......
...@@ -21,7 +21,6 @@ import android.net.Uri; ...@@ -21,7 +21,6 @@ import android.net.Uri;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException; import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import org.junit.Test; import org.junit.Test;
...@@ -57,7 +56,7 @@ public final class DefaultLoadErrorHandlingPolicyTest { ...@@ -57,7 +56,7 @@ public final class DefaultLoadErrorHandlingPolicyTest {
@Test @Test
public void getBlacklistDurationMsFor_dontBlacklistUnexpectedExceptions() { public void getBlacklistDurationMsFor_dontBlacklistUnexpectedExceptions() {
FileNotFoundException exception = new FileNotFoundException(); IOException exception = new IOException();
assertThat(getDefaultPolicyBlacklistOutputFor(exception)).isEqualTo(C.TIME_UNSET); assertThat(getDefaultPolicyBlacklistOutputFor(exception)).isEqualTo(C.TIME_UNSET);
} }
...@@ -69,9 +68,9 @@ public final class DefaultLoadErrorHandlingPolicyTest { ...@@ -69,9 +68,9 @@ public final class DefaultLoadErrorHandlingPolicyTest {
@Test @Test
public void getRetryDelayMsFor_successiveRetryDelays() { public void getRetryDelayMsFor_successiveRetryDelays() {
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 3)).isEqualTo(2000); assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 3)).isEqualTo(2000);
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 5)).isEqualTo(4000); assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 5)).isEqualTo(4000);
assertThat(getDefaultPolicyRetryDelayOutputFor(new FileNotFoundException(), 9)).isEqualTo(5000); assertThat(getDefaultPolicyRetryDelayOutputFor(new IOException(), 9)).isEqualTo(5000);
} }
private static long getDefaultPolicyBlacklistOutputFor(IOException exception) { private static long getDefaultPolicyBlacklistOutputFor(IOException exception) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment