From d2bb7a50f5133aadd5efd46c3338b73e811bf7b5 Mon Sep 17 00:00:00 2001 From: MAKARD01 Date: Wed, 21 Feb 2024 10:53:33 +0200 Subject: [PATCH 1/2] fix: Clear updates on initializeUpdateAfterRestart in case codepush.json is corrupted --- .../java/com/microsoft/codepush/react/CodePush.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index 4acb84fce..a7d51d971 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -295,7 +295,16 @@ void initializeUpdateAfterRestart() { JSONObject pendingUpdate = mSettingsManager.getPendingUpdate(); if (pendingUpdate != null) { - JSONObject packageMetadata = this.mUpdateManager.getCurrentPackage(); + JSONObject packageMetadata = null; + + try { + packageMetadata = this.mUpdateManager.getCurrentPackage(); + } catch (CodePushMalformedDataException e) { + // We need to recover the app in case 'codepush.json' is corrupted + CodePushUtils.log(e.getMessage()); + clearUpdates(); + return; + } if (packageMetadata == null || !isPackageBundleLatest(packageMetadata) && hasBinaryVersionChanged(packageMetadata)) { CodePushUtils.log("Skipping initializeUpdateAfterRestart(), binary version is newer"); return; From d9011255a244e5dc2285c5b8be5be4eab349ad43 Mon Sep 17 00:00:00 2001 From: MAKARD01 Date: Tue, 5 Mar 2024 21:23:10 +0200 Subject: [PATCH 2/2] fix: Log the complete error instead of only message --- .../src/main/java/com/microsoft/codepush/react/CodePush.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java index a7d51d971..2718204d6 100644 --- a/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +++ b/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java @@ -301,7 +301,7 @@ void initializeUpdateAfterRestart() { packageMetadata = this.mUpdateManager.getCurrentPackage(); } catch (CodePushMalformedDataException e) { // We need to recover the app in case 'codepush.json' is corrupted - CodePushUtils.log(e.getMessage()); + CodePushUtils.log(e); clearUpdates(); return; }