Skip to content

Commit

Permalink
[unimodules-app-loader] Fixes Class Name Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
thorbenprimke committed May 13, 2020
1 parent 069e9fc commit 8223f9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 8223f9b

Please sign in to comment.