Skip to content

Commit 73094cf

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Fix deprecation warnings in NetworkEventUtilTest
Summary: Android builds have been failing with the following: ``` > Task :packages:react-native:ReactAndroid:compileDebugOptimizedUnitTestKotlin e: warnings found and -Werror specified w: file:///__w/react-native/react-native/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkEventUtilTest.kt:309:28 'fun create(contentType: MediaType?, content: String): RequestBody' is deprecated. Moved to extension function. Put the 'content' argument first to fix Java. w: file:///__w/react-native/react-native/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkEventUtilTest.kt:317:29 'fun create(contentType: MediaType?, content: String): RequestBody' is deprecated. Moved to extension function. Put the 'content' argument first to fix Java. ``` Warnings show as errors but we're not on OkHttp 4 yet and don't have extension functions, so it's fine to suppress these for now. Changelog: [Internal] Differential Revision: D106200232
1 parent b32a6c9 commit 73094cf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkEventUtilTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ class NetworkEventUtilTest {
306306
@Test
307307
fun testGetRequestBodyPreviewReturnsBodyForStringRequest() {
308308
val payload = """{"key":"value"}"""
309+
@Suppress("DEPRECATION")
309310
val body = RequestBody.create(MediaType.parse("application/json"), payload)
310311

311312
assertThat(NetworkEventUtil.getRequestBodyPreview(body)).isEqualTo(payload)
@@ -314,7 +315,7 @@ class NetworkEventUtilTest {
314315
@Test
315316
fun testGetRequestBodyPreviewUnwrapsProgressRequestBody() {
316317
val payload = "hello world"
317-
val inner = RequestBody.create(MediaType.parse("text/plain"), payload)
318+
@Suppress("DEPRECATION") val inner = RequestBody.create(MediaType.parse("text/plain"), payload)
318319
val wrapped = ProgressRequestBody(inner) { _, _, _ -> }
319320

320321
assertThat(NetworkEventUtil.getRequestBodyPreview(wrapped)).isEqualTo(payload)

0 commit comments

Comments
 (0)