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

Commit 964530c

Browse files
Yuri Kulikovalexandergoncharov-zz
authored andcommitted
Handle codepush.json parsing exception (#1540)
1 parent 137067c commit 964530c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,15 @@ public String getJSBundleFileInternal(String assetsBundleFileName) {
213213
this.mAssetsBundleFileName = assetsBundleFileName;
214214
String binaryJsBundleUrl = CodePushConstants.ASSETS_BUNDLE_PREFIX + assetsBundleFileName;
215215

216-
String packageFilePath = mUpdateManager.getCurrentPackageBundlePath(this.mAssetsBundleFileName);
216+
String packageFilePath = null;
217+
try {
218+
packageFilePath = mUpdateManager.getCurrentPackageBundlePath(this.mAssetsBundleFileName);
219+
} catch (CodePushMalformedDataException e) {
220+
// We need to recover the app in case 'codepush.json' is corrupted
221+
CodePushUtils.log(e.getMessage());
222+
clearUpdates();
223+
}
224+
217225
if (packageFilePath == null) {
218226
// There has not been any downloaded updates.
219227
CodePushUtils.logBundleUrl(binaryJsBundleUrl);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ protected Void doInBackground(Void... params) {
349349
CodePushUtils.setJSONValueForKey(currentPackage, "isPending", currentUpdateIsPending);
350350
promise.resolve(CodePushUtils.convertJsonObjectToWritable(currentPackage));
351351
}
352+
} catch (CodePushMalformedDataException e) {
353+
// We need to recover the app in case 'codepush.json' is corrupted
354+
CodePushUtils.log(e.getMessage());
355+
clearUpdates();
356+
promise.resolve(null);
352357
} catch(CodePushUnknownException e) {
353358
CodePushUtils.log(e);
354359
promise.reject(e);

0 commit comments

Comments
 (0)