Fix CircleCI removing lambda in Java (#36458)

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

Our CircleCI infra does not support lambda yet.
Over the weekend, a stack of multiple Android changes landed and one of those diff had a lambda that was not fixed. See this [workflow](https://app.circleci.com/pipelines/github/facebook/react-native/20276/workflows/e73bf98e-12e0-47e3-8bff-a42f6c40798e/jobs/474761).

After the lambda was fixed, another issue related to the `reactApplicationContext` being accessed from an inner class without being `final` [occurred](https://app.circleci.com/pipelines/github/facebook/react-native/20286/workflows/70dab2f0-ee71-4510-8611-c5d29ea4cfae/jobs/475379).

This change should fix these problems.

## Changelog
[Android][Fixed] - Make CircleCI green

Reviewed By: cortinico

Differential Revision: D44019871

fbshipit-source-id: 1a6e39446b0ba2f5a395f54b58a70b67590ee154
This commit is contained in:
Riccardo Cipolleschi
2023-03-13 04:59:22 -07:00
committed by Facebook GitHub Bot
parent cfa03db98b
commit 348a99a7c8
@@ -43,13 +43,14 @@ public abstract class ReactPackageTurboModuleManagerDelegate extends TurboModule
protected ReactPackageTurboModuleManagerDelegate(
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
super();
final ReactApplicationContext applicationContext = reactApplicationContext;
for (ReactPackage reactPackage : packages) {
if (reactPackage instanceof TurboReactPackage) {
final TurboReactPackage turboPkg = (TurboReactPackage) reactPackage;
final ModuleProvider moduleProvider =
new ModuleProvider() {
public NativeModule getModule(String moduleName) {
return turboPkg.getModule(moduleName, reactApplicationContext);
return turboPkg.getModule(moduleName, applicationContext);
}
};
mModuleProviders.add(moduleProvider);
@@ -68,9 +69,11 @@ public abstract class ReactPackageTurboModuleManagerDelegate extends TurboModule
}
final ModuleProvider moduleProvider =
(name) -> {
Provider<? extends NativeModule> provider = moduleSpecProviderMap.get(name);
return provider != null ? provider.get() : null;
new ModuleProvider() {
public NativeModule getModule(String moduleName) {
Provider<? extends NativeModule> provider = moduleSpecProviderMap.get(moduleName);
return provider != null ? provider.get() : null;
}
};
mModuleProviders.add(moduleProvider);