Skip to content

Commit 2b5bcf6

Browse files
committed
make 3p call safe
1 parent 1c03e67 commit 2b5bcf6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/NoOpInternalSdkCore.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import okhttp3.OkHttpClient
2626
import okhttp3.Request
2727
import okhttp3.Response
2828
import java.io.File
29+
import java.net.HttpURLConnection
2930
import java.util.UUID
3031
import java.util.concurrent.Callable
3132
import java.util.concurrent.Delayed
@@ -315,8 +316,16 @@ internal object NoOpInternalSdkCore : InternalSdkCore {
315316

316317
override fun enqueue(responseCallback: okhttp3.Callback) = Unit
317318

319+
@Suppress("UnsafeThirdPartyFunctionCall") // All required fields are set, won't throw
318320
override fun execute(): Response {
319-
return Response.Builder().build()
321+
// Response.Builder.build() requires: request, protocol, code, and message
322+
// to be set, otherwise it throws IllegalStateException
323+
return Response.Builder()
324+
.request(originalRequest)
325+
.protocol(okhttp3.Protocol.HTTP_1_1)
326+
.code(HttpURLConnection.HTTP_OK)
327+
.message("OK")
328+
.build()
320329
}
321330

322331
override fun isCanceled(): Boolean {

0 commit comments

Comments
 (0)