Skip to content

Commit cb273b9

Browse files
sumchatteringclaude
andcommitted
Fix NPE in syncWithRemoteQueue when message is removed during sync (#485)
Add null check for localMessage after re-fetching from storage to guard against a race condition where the message is removed between the existence check and the retrieval. Fixes #485 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 072973f commit cb273b9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppManager.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,14 @@ private void syncWithRemoteQueue(List<IterableInAppMessage> remoteQueue) {
353353
if (isInAppStored) {
354354
IterableInAppMessage localMessage = storage.getMessage(message.getMessageId());
355355

356-
boolean shouldOverwriteInApp = !localMessage.isRead() && message.isRead();
356+
if (localMessage != null) {
357+
boolean shouldOverwriteInApp = !localMessage.isRead() && message.isRead();
357358

358-
if (shouldOverwriteInApp) {
359-
localMessage.setRead(message.isRead());
359+
if (shouldOverwriteInApp) {
360+
localMessage.setRead(message.isRead());
360361

361-
changed = true;
362+
changed = true;
363+
}
362364
}
363365
}
364366
}

0 commit comments

Comments
 (0)