Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-2528 prevent crash on peekBody #1080

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ internal constructor(
val contentLength = body.contentLength()
if (contentLength == 0L) null else contentLength
} catch (e: IOException) {
sdkLogger.e("Unable to peek response body", e)
sdkLogger.e(ERROR_PEEK_BODY, e)
null
} catch (e: IllegalStateException) {
sdkLogger.e(ERROR_PEEK_BODY, e)
null
} catch (e: IllegalArgumentException) {
sdkLogger.e(ERROR_PEEK_BODY, e)
null
}
}
Expand All @@ -273,6 +279,8 @@ internal constructor(
internal const val ERROR_NO_RESPONSE =
"The request ended with no response nor any exception."

internal const val ERROR_PEEK_BODY = "Unable to peek response body."

internal const val ERROR_MSG_FORMAT = "OkHttp request error %s %s"

internal const val ORIGIN_RUM = "rum"
Expand Down
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ datadog:
# region OkHttp
- "okhttp3.Call.execute():java.io.IOException"
- "okhttp3.Dns.lookup(kotlin.String):java.net.UnknownHostException"
- "okhttp3.Response.peekBody(kotlin.Long):java.io.IOException"
- "okhttp3.Response.peekBody(kotlin.Long):java.io.IOException,java.lang.IllegalArgumentException,java.lang.IllegalStateException"
- "okhttp3.RequestBody.writeTo(okio.BufferedSink):java.io.IOException"
- "okhttp3.Response.close():java.lang.IllegalStateException"
- "okhttp3.Request.Builder.build():java.lang.IllegalStateException"
Expand Down