Skip to content

Commit

Permalink
deduplicate code in cleanDataFromModules (facebook#39767)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#39767

deduplicate code in cleanDataFromModules

changelog: [internal] internal

bypass-github-export-checks

Reviewed By: cortinico

Differential Revision: D49834866

fbshipit-source-id: 6b54a0cfcd58e9c963125d07b736e1377a548393
  • Loading branch information
mdvacca authored and facebook-github-bot committed Oct 4, 2023
1 parent d0bb2e4 commit 353d8d3
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.ReactConstants;
import java.util.Collection;

/**
* Cleans sensitive user data from native modules that implement the {@code Cleanable} interface.
Expand Down Expand Up @@ -45,16 +46,15 @@ public interface Cleanable {
*/
@Deprecated
public static void cleanDataFromModules(CatalystInstance catalystInstance) {
for (NativeModule nativeModule : catalystInstance.getNativeModules()) {
if (nativeModule instanceof Cleanable) {
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
((Cleanable) nativeModule).clearSensitiveData();
}
}
cleanDataFromModules(catalystInstance.getNativeModules());
}

public static void cleanDataFromModules(ReactContext reactContext) {
for (NativeModule nativeModule : reactContext.getNativeModules()) {
cleanDataFromModules(reactContext.getNativeModules());
}

private static void cleanDataFromModules(Collection<NativeModule> nativeModules) {
for (NativeModule nativeModule : nativeModules) {
if (nativeModule instanceof Cleanable) {
FLog.d(ReactConstants.TAG, "Cleaning data from " + nativeModule.getName());
((Cleanable) nativeModule).clearSensitiveData();
Expand Down

0 comments on commit 353d8d3

Please sign in to comment.