jimu-decompiled/sources/com/alibaba/sdk/android/oss/internal/OSSRetryHandler.java
2025-05-13 19:24:51 +02:00

67 lines
2.5 KiB
Java

package com.alibaba.sdk.android.oss.internal;
import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.ServiceException;
import com.alibaba.sdk.android.oss.common.OSSLog;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
/* loaded from: classes.dex */
public class OSSRetryHandler {
private int a = 2;
/* renamed from: com.alibaba.sdk.android.oss.internal.OSSRetryHandler$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[OSSRetryType.values().length];
static {
try {
a[OSSRetryType.OSSRetryTypeShouldRetry.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
}
}
public OSSRetryHandler(int i) {
a(i);
}
public void a(int i) {
this.a = i;
}
public OSSRetryType a(Exception exc, int i) {
if (i >= this.a) {
return OSSRetryType.OSSRetryTypeShouldNotRetry;
}
if (!(exc instanceof ClientException)) {
if (!(exc instanceof ServiceException)) {
return OSSRetryType.OSSRetryTypeShouldNotRetry;
}
ServiceException serviceException = (ServiceException) exc;
return (serviceException.getErrorCode() == null || !serviceException.getErrorCode().equalsIgnoreCase("RequestTimeTooSkewed")) ? serviceException.getStatusCode() >= 500 ? OSSRetryType.OSSRetryTypeShouldRetry : OSSRetryType.OSSRetryTypeShouldNotRetry : OSSRetryType.OSSRetryTypeShouldFixedTimeSkewedAndRetry;
}
if (((ClientException) exc).isCanceledException().booleanValue()) {
return OSSRetryType.OSSRetryTypeShouldNotRetry;
}
Exception exc2 = (Exception) exc.getCause();
if ((exc2 instanceof InterruptedIOException) && !(exc2 instanceof SocketTimeoutException)) {
OSSLog.b("[shouldRetry] - is interrupted!");
return OSSRetryType.OSSRetryTypeShouldNotRetry;
}
if (exc2 instanceof IllegalArgumentException) {
return OSSRetryType.OSSRetryTypeShouldNotRetry;
}
OSSLog.a("shouldRetry - " + exc.toString());
exc.getCause().printStackTrace();
return OSSRetryType.OSSRetryTypeShouldRetry;
}
public long a(int i, OSSRetryType oSSRetryType) {
if (AnonymousClass1.a[oSSRetryType.ordinal()] != 1) {
return 0L;
}
return ((long) Math.pow(2.0d, i)) * 200;
}
}