[SDK-417] Fail gracefully when managers accessed before init#1073
Open
franco-zalamena-iterable wants to merge 1 commit into
Open
[SDK-417] Fail gracefully when managers accessed before init#1073franco-zalamena-iterable wants to merge 1 commit into
franco-zalamena-iterable wants to merge 1 commit into
Conversation
getInAppManager() and getEmbeddedManager() threw a RuntimeException when called before IterableApi.initialize(), crashing the host app for a call- ordering mistake. They now log a warning and return a no-op manager (empty lists, ignored commands) instead, matching the iOS SDK's null-object model. The getters keep their concrete @nonnull return types, so no existing call site or test needs to change. Two no-op subclasses (EmptyInAppManager, EmptyEmbeddedManager) back the stub. New getInAppManagerOrNull() / getEmbeddedManagerOrNull() return null pre-init for callers that want to detect the uninitialized state explicitly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rtlsilva
reviewed
Jul 10, 2026
| * usage error. Use [IterableApi.getEmbeddedManagerOrNull] to detect this state explicitly. | ||
| */ | ||
| internal class EmptyEmbeddedManager : IterableEmbeddedManager() { | ||
|
|
There was a problem hiding this comment.
EmptyInAppManager defines its own private static final String TAG = "EmptyInAppManager";, while this EmptyEmbeddedManager does not.
This means that a pre-init error on the embedded side will get tagged with the base IterableEmbeddedManager tag, while one in the in-app side will get tagged with the easier to find EmptyInAppManager.
Suggest adding an EmptyEmbeddedManager tag constant for consistency.
Suggested change
| private const val TAG = "EmptyEmbeddedManager" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔹 Jira Ticket(s) if any
✏️ Description
Fix to prevent calls before initialization to crash the app. We now log an error and have a new way to get the Iterable instance or null on the spot.