Skip to content

Commit c71df6b

Browse files
authored
Guard against NPE (#388)
1 parent 0f0233b commit c71df6b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

AndroidSDKCore/src/main/java/com/leanplum/internal/LeanplumInternal.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,21 @@ public void variablesChanged() {
279279
}
280280

281281
private static int fetchCountDown(ActionContext context, Map<String, Object> messages) {
282+
if (context == null || messages == null) {
283+
return 0;
284+
}
285+
282286
// Get eta.
283-
Object countdownObj;
284287
if (((BaseActionContext) context).isPreview()) {
285-
countdownObj = 5.0;
288+
return 5;
286289
} else {
287290
Map<String, Object> messageConfig = CollectionUtil.uncheckedCast(messages.get(context.messageId));
288-
countdownObj = messageConfig.get("countdown");
291+
Object countdown = messageConfig.get("countdown");
292+
if (countdown instanceof Number) {
293+
return ((Number) countdown).intValue();
294+
}
295+
return 0;
289296
}
290-
return ((Number) countdownObj).intValue();
291297
}
292298

293299
private static Map<String, Object> makeTrackArgs(final String event, double value, String info,

0 commit comments

Comments
 (0)