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 @@ -172,12 +172,16 @@ internal class DataOkHttpUploader(
172172 ): UploadStatus {
173173 return when (code) {
174174 HTTP_ACCEPTED -> UploadStatus .Success (code)
175- HTTP_BAD_REQUEST -> UploadStatus . HttpClientError (code)
176- HTTP_UNAUTHORIZED -> UploadStatus . InvalidTokenError (code)
175+
176+ HTTP_UNAUTHORIZED ,
177177 HTTP_FORBIDDEN -> UploadStatus .InvalidTokenError (code)
178- HTTP_CLIENT_TIMEOUT -> UploadStatus . HttpClientRateLimiting (code)
179- HTTP_ENTITY_TOO_LARGE -> UploadStatus . HttpClientError (code)
178+
179+ HTTP_CLIENT_TIMEOUT ,
180180 HTTP_TOO_MANY_REQUESTS -> UploadStatus .HttpClientRateLimiting (code)
181+
182+ HTTP_BAD_REQUEST ,
183+ HTTP_ENTITY_TOO_LARGE -> UploadStatus .HttpClientError (code)
184+
181185 HTTP_INTERNAL_ERROR ,
182186 HTTP_BAD_GATEWAY ,
183187 HTTP_UNAVAILABLE ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ internal sealed class UploadStatus(
1515) {
1616
1717 internal class Success (responseCode : Int ) : UploadStatus(shouldRetry = false , code = responseCode)
18+
1819 internal class NetworkError (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
1920 internal class DNSError (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
2021 internal class RequestCreationError (throwable : Throwable ? ) :
@@ -26,6 +27,7 @@ internal sealed class UploadStatus(
2627 internal class HttpServerError (responseCode : Int ) : UploadStatus(shouldRetry = true , code = responseCode)
2728 internal class HttpClientRateLimiting (responseCode : Int ) : UploadStatus(shouldRetry = true , code = responseCode)
2829 internal class UnknownHttpError (responseCode : Int ) : UploadStatus(shouldRetry = false , code = responseCode)
30+
2931 internal class UnknownException (throwable : Throwable ) : UploadStatus(shouldRetry = true , throwable = throwable)
3032
3133 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(
9797 RemovalReason .IntakeCode (uploadStatus.code),
9898 deleteBatch = ! uploadStatus.shouldRetry
9999 )
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+ }
102104 }
103105 }
104106
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ internal sealed class RemovalReason {
1111 internal fun includeInMetrics (): Boolean {
1212 return this !is Flushed
1313 }
14- internal class IntakeCode (private val responseCode : Int ) : RemovalReason() {
14+ internal data class IntakeCode (private val responseCode : Int ) : RemovalReason() {
1515 override fun toString (): String {
1616 return " intake-code-$responseCode "
1717 }
You can’t perform that action at this time.
0 commit comments