Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 30b2733

Browse files
committed
Check that the previous package is not null
1 parent abc1c77 commit 30b2733

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
public class CodePushNativeModule extends ReactContextBaseJavaModule {
3636
private String mBinaryContentsHash = null;
37-
private String mClientUniqueId = null;
37+
private String mClientUniqueId = null;
3838
private LifecycleEventListener mLifecycleEventListener = null;
3939
private int mMinimumBackgroundDuration = 0;
4040

@@ -105,7 +105,7 @@ private void loadBundle() {
105105
if (instanceManager == null) {
106106
return;
107107
}
108-
108+
109109
String latestJSBundleFile = mCodePush.getJSBundleFileInternal(mCodePush.getAssetsBundleFileName());
110110

111111
// #2) Update the locally stored JS bundle file path
@@ -146,7 +146,7 @@ public void run() {
146146
loadBundleLegacy();
147147
}
148148
}
149-
149+
150150
private ReactInstanceManager resolveInstanceManager() throws NoSuchFieldException, IllegalAccessException {
151151
ReactInstanceManager instanceManager = CodePush.getReactInstanceManager();
152152
if (instanceManager != null) {
@@ -304,7 +304,14 @@ protected Void doInBackground(Void... params) {
304304
} else if (updateState == CodePushUpdateState.RUNNING.getValue() && currentUpdateIsPending) {
305305
// The caller wants the running update, but the current
306306
// one is pending, so we need to grab the previous.
307-
promise.resolve(CodePushUtils.convertJsonObjectToWritable(mUpdateManager.getPreviousPackage()));
307+
JSONObject previousPackage = mUpdateManager.getPreviousPackage();
308+
309+
if (previousPackage == null) {
310+
promise.resolve("");
311+
return null;
312+
}
313+
314+
promise.resolve(CodePushUtils.convertJsonObjectToWritable(previousPackage));
308315
} else {
309316
// The current package satisfies the request:
310317
// 1) Caller wanted a pending, and there is a pending update

0 commit comments

Comments
 (0)