File tree Expand file tree Collapse file tree 5 files changed +685
-469
lines changed
main/kotlin/com/datadog/android/core/internal
test/kotlin/com/datadog/android/core/internal/data/upload Expand file tree Collapse file tree 5 files changed +685
-469
lines changed Original file line number Diff line number Diff line change @@ -183,12 +183,16 @@ internal class DataOkHttpUploader(
183
183
): UploadStatus {
184
184
return when (code) {
185
185
HTTP_ACCEPTED -> UploadStatus .Success (code)
186
- HTTP_BAD_REQUEST -> UploadStatus . HttpClientError (code)
187
- HTTP_UNAUTHORIZED -> UploadStatus . InvalidTokenError (code)
186
+
187
+ HTTP_UNAUTHORIZED ,
188
188
HTTP_FORBIDDEN -> UploadStatus .InvalidTokenError (code)
189
- HTTP_CLIENT_TIMEOUT -> UploadStatus . HttpClientRateLimiting (code)
190
- HTTP_ENTITY_TOO_LARGE -> UploadStatus . HttpClientError (code)
189
+
190
+ HTTP_CLIENT_TIMEOUT ,
191
191
HTTP_TOO_MANY_REQUESTS -> UploadStatus .HttpClientRateLimiting (code)
192
+
193
+ HTTP_BAD_REQUEST ,
194
+ HTTP_ENTITY_TOO_LARGE -> UploadStatus .HttpClientError (code)
195
+
192
196
HTTP_INTERNAL_ERROR ,
193
197
HTTP_BAD_GATEWAY ,
194
198
HTTP_UNAVAILABLE ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ internal sealed class UploadStatus(
15
15
) {
16
16
17
17
internal class Success (responseCode : Int ) : UploadStatus(shouldRetry = false , code = responseCode)
18
+
18
19
internal class NetworkError (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
19
20
internal class DNSError (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
20
21
internal class RequestCreationError (throwable : Throwable ? ) :
@@ -26,6 +27,7 @@ internal sealed class UploadStatus(
26
27
internal class HttpServerError (responseCode : Int ) : UploadStatus(shouldRetry = true , code = responseCode)
27
28
internal class HttpClientRateLimiting (responseCode : Int ) : UploadStatus(shouldRetry = true , code = responseCode)
28
29
internal class UnknownHttpError (responseCode : Int ) : UploadStatus(shouldRetry = false , code = responseCode)
30
+
29
31
internal class UnknownException (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
30
32
31
33
internal object UnknownStatus : UploadStatus(shouldRetry = false , code = UNKNOWN_RESPONSE_CODE )
Original file line number Diff line number Diff line change @@ -97,8 +97,10 @@ internal class UploadWorker(
97
97
RemovalReason .IntakeCode (uploadStatus.code),
98
98
deleteBatch = ! uploadStatus.shouldRetry
99
99
)
100
- @Suppress(" UnsafeThirdPartyFunctionCall" ) // safe to add
101
- taskQueue.offer(UploadNextBatchTask (taskQueue, sdkCore, feature))
100
+ if (uploadStatus is UploadStatus .Success ) {
101
+ @Suppress(" UnsafeThirdPartyFunctionCall" ) // safe to add
102
+ taskQueue.offer(UploadNextBatchTask (taskQueue, sdkCore, feature))
103
+ }
102
104
}
103
105
}
104
106
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ internal sealed class RemovalReason {
11
11
internal fun includeInMetrics (): Boolean {
12
12
return this !is Flushed
13
13
}
14
- internal class IntakeCode (private val responseCode : Int ) : RemovalReason() {
14
+ internal data class IntakeCode (private val responseCode : Int ) : RemovalReason() {
15
15
override fun toString (): String {
16
16
return " intake-code-$responseCode "
17
17
}
You can’t perform that action at this time.
0 commit comments