Back out "Kotlinify OkHttpCallUtil" (#43857)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43857

Changelog: [Internal]

There seems to be a weird problem with OkHttpCallUtil:
* D55707704 works in fbsource but breaks the CircleCI build with

> using 'dispatcher(): Dispatcher' is an error. moved to val

* D55744165 fixes the CircleCI build but breaks in fbsource with

> cannot access 'dispatcher': it is package-private in 'OkHttpClient'

Not sure what's the real fix to migrate `OkHttpCallUtil` to Koltin but at this point is probably safer to backout the original migration! 😥

Reviewed By: cortinico

Differential Revision: D55745345

fbshipit-source-id: 3ec6e4d99c950098fae974aa5f0e5be0b6663249
This commit is contained in:
Fabrizio Cucci
2024-04-04 08:25:14 -07:00
committed by Facebook GitHub Bot
parent 0b6b8e2fe6
commit 6bac579a12
3 changed files with 38 additions and 35 deletions
@@ -1936,9 +1936,8 @@ public final class com/facebook/react/common/mapbuffer/WritableMapBuffer : com/f
public final fun put (IZ)Lcom/facebook/react/common/mapbuffer/WritableMapBuffer;
}
public final class com/facebook/react/common/network/OkHttpCallUtil {
public static final field INSTANCE Lcom/facebook/react/common/network/OkHttpCallUtil;
public static final fun cancelTag (Lokhttp3/OkHttpClient;Ljava/lang/Object;)V
public class com/facebook/react/common/network/OkHttpCallUtil {
public static fun cancelTag (Lokhttp3/OkHttpClient;Ljava/lang/Object;)V
}
public class com/facebook/react/config/ReactFeatureFlags {
@@ -0,0 +1,36 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.common.network;
import com.facebook.infer.annotation.Nullsafe;
import okhttp3.Call;
import okhttp3.OkHttpClient;
/**
* Helper class that provides the necessary methods for canceling queued and running OkHttp calls
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class OkHttpCallUtil {
private OkHttpCallUtil() {}
public static void cancelTag(OkHttpClient client, Object tag) {
for (Call call : client.dispatcher().queuedCalls()) {
if (tag.equals(call.request().tag())) {
call.cancel();
return;
}
}
for (Call call : client.dispatcher().runningCalls()) {
if (tag.equals(call.request().tag())) {
call.cancel();
return;
}
}
}
}
@@ -1,32 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.common.network
import okhttp3.OkHttpClient
/**
* Helper class that provides the necessary methods for canceling queued and running OkHttp calls
*/
public object OkHttpCallUtil {
@JvmStatic
public fun cancelTag(client: OkHttpClient, tag: Any) {
for (call in client.dispatcher().queuedCalls()) {
if (tag == call.request().tag()) {
call.cancel()
return
}
}
for (call in client.dispatcher().runningCalls()) {
if (tag == call.request().tag()) {
call.cancel()
return
}
}
}
}