Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[unimodules-app-loader] Fixes Class Name Cache #8292

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/unimodules-app-loader/CHANGELOG.md
Expand Up @@ -7,3 +7,5 @@
### 🎉 New features

### 🐛 Bug fixes

- Fixed `appLoaderRegisteredForName` to not only check if a loader class name is in the cache for the provided name but also verifies that the cached and current class name match. When migrating from managed to bare, the class name cache needs to be updated. ([#8292](https://github.com/expo/expo/pull/8292) by [@thorbenprimke](https://github.com/thorbenprimke))
Expand Up @@ -18,7 +18,7 @@ public static void registerLoader(Context context, String name, Class loaderClas

public static void registerLoader(Context context, String name, Class loaderClass, boolean overload) {
if (!overload) {
if (appLoaderRegisteredForName(context, name)) return;
if (appLoaderRegisteredForName(context, name, loaderClass)) return;
}
getSharedPreferences(context).edit()
.putString(appLoaderKey(name), loaderClass.getName())
Expand All @@ -39,8 +39,9 @@ public static HeadlessAppLoader getLoader(String name, Context context) {
return loaders.get(name);
}

private static boolean appLoaderRegisteredForName(Context context, String name) {
return loaderClasses.containsKey(name) || getSharedPreferences(context).getString(appLoaderKey(name), null) != null;
private static boolean appLoaderRegisteredForName(Context context, String name, Class loaderClass) {
String cachedClassName = getSharedPreferences(context).getString(appLoaderKey(name), null);
return loaderClasses.containsKey(name) || loaderClass.getName().equals(cachedClassName);
}

private static void createLoader(String name, Context context) throws ClassNotFoundException, IllegalAccessException, InstantiationException, java.lang.reflect.InvocationTargetException, NoSuchMethodException {
Expand Down