Skip to content

Commit 82dc858

Browse files
committed
Merge pull request #11 from Leanplum/feature/fix-LP-4496
fix(NPE): fix NPE at VarCache.java.
1 parent 60b8b2d commit 82dc858

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

AndroidSDK/src/com/leanplum/internal/VarCache.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,14 @@ static int getResIdFromPath(String resPath) {
465465
private static void fileVariableFinish() {
466466
for (String name : new HashMap<>(vars).keySet()) {
467467
Var<?> var = vars.get(name);
468+
if (var == null) {
469+
return;
470+
}
468471
String overrideFile = var.stringValue;
469-
if (var.isResource && (var.kind().equals(Constants.Kinds.FILE)) && overrideFile != null &&
470-
!var.defaultValue().equals(overrideFile)) {
472+
if (var.isResource && Constants.Kinds.FILE.equals(var.kind()) && overrideFile != null &&
473+
!overrideFile.equals(var.defaultValue())) {
471474
Map<String, Object> variationAttributes = CollectionUtil.uncheckedCast(fileAttributes.get
472-
(overrideFile));
475+
(overrideFile));
473476
InputStream stream = fileStreams.get(overrideFile);
474477
if (variationAttributes != null && stream != null) {
475478
var.setOverrideResId(getResIdFromPath(var.stringValue()));
@@ -520,7 +523,7 @@ public static void applyVariableDiffs(
520523
String name = entry.getKey();
521524
Map<String, Object> messageConfig = CollectionUtil.uncheckedCast(VarCache.messages.get
522525
(name));
523-
if (messageConfig.get("action") != null) {
526+
if (messageConfig != null && messageConfig.get("action") != null) {
524527
Map<String, Object> actionArgs =
525528
CollectionUtil.uncheckedCast(messageConfig.get(Constants.Keys.VARS));
526529
new ActionContext(

0 commit comments

Comments
 (0)