Make position-out-of-range errors non-retryable

PiperOrigin-RevId: 396354920
This commit is contained in:
olly 2021-09-13 15:50:14 +01:00 committed by Christos Tsilopoulos
parent 469c0e756a
commit 4940f21d48

View File

@ -101,8 +101,9 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
/**
* Retries for any exception that is not a subclass of {@link ParserException}, {@link
* FileNotFoundException}, {@link CleartextNotPermittedException} or {@link
* UnexpectedLoaderException}. The retry delay is calculated as {@code Math.min((errorCount - 1) *
* 1000, 5000)}.
* UnexpectedLoaderException}, and for which {@link
* DataSourceException#isCausedByPositionOutOfRange} returns {@code false}. The retry delay is
* calculated as {@code Math.min((errorCount - 1) * 1000, 5000)}.
*/
@Override
public long getRetryDelayMsFor(LoadErrorInfo loadErrorInfo) {
@ -111,6 +112,7 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
|| exception instanceof FileNotFoundException
|| exception instanceof CleartextNotPermittedException
|| exception instanceof UnexpectedLoaderException
|| DataSourceException.isCausedByPositionOutOfRange(exception)
? C.TIME_UNSET
: min((loadErrorInfo.errorCount - 1) * 1000, 5000);
}