Skip to content

Commit 353d8d3

Browse files
mdvaccafacebook-github-bot
authored andcommitted
deduplicate code in cleanDataFromModules (#39767)
Summary: Pull Request resolved: #39767 deduplicate code in cleanDataFromModules changelog: [internal] internal bypass-github-export-checks Reviewed By: cortinico Differential Revision: D49834866 fbshipit-source-id: 6b54a0cfcd58e9c963125d07b736e1377a548393
1 parent d0bb2e4 commit 353d8d3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/common/ModuleDataCleaner.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.facebook.react.bridge.NativeModule;
1313
import com.facebook.react.bridge.ReactContext;
1414
import com.facebook.react.common.ReactConstants;
15+
import java.util.Collection;
1516

1617
/**
1718
* Cleans sensitive user data from native modules that implement the {@code Cleanable} interface.
@@ -45,16 +46,15 @@ public interface Cleanable {
4546
*/
4647
@Deprecated
4748
public static void cleanDataFromModules(CatalystInstance catalystInstance) {
48-
for (NativeModule nativeModule : catalystInstance.getNativeModules()) {
49-
if (nativeModule instanceof Cleanable) {
50-
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
51-
((Cleanable) nativeModule).clearSensitiveData();
52-
}
53-
}
49+
cleanDataFromModules(catalystInstance.getNativeModules());
5450
}
5551

5652
public static void cleanDataFromModules(ReactContext reactContext) {
57-
for (NativeModule nativeModule : reactContext.getNativeModules()) {
53+
cleanDataFromModules(reactContext.getNativeModules());
54+
}
55+
56+
private static void cleanDataFromModules(Collection<NativeModule> nativeModules) {
57+
for (NativeModule nativeModule : nativeModules) {
5858
if (nativeModule instanceof Cleanable) {
5959
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
6060
((Cleanable) nativeModule).clearSensitiveData();

0 commit comments

Comments
 (0)