Open
Conversation
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Show resolved
Hide resolved
Ayyanchira
commented
Feb 23, 2026
Member
Author
Ayyanchira
left a comment
There was a problem hiding this comment.
Self review until OfflienRequestProcessor.java
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Outdated
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Outdated
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableTaskRunner.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableTaskRunner.java
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableTaskRunner.java
Outdated
Show resolved
Hide resolved
iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java
Show resolved
Hide resolved
Includes 1. getRemoteConfiguration checking for the flag. And assuming false if no values exist. Also stores in sharedPreferences to load from it next time. 2. isAutoRetryOnJWTFailure on `IterableAPI` which other classes with use. Not public. 3. Introduced three states which Taskmanager can rely on. VALID, INVALID, UNKNOWN. 4. Listener pub/sub added which will invoke onAuthTokenReady() on listner class. Adding array of AuthTokenReadyListener on Authmanager and its add and remove list methods. 5. Right now authHandler null returns true hoping to bypass jwt. But JWT based request will fail if API needs jwt. This could pile up storage. But this seems like a valid scenario 6. handleAuthTokenSucess sets authtoken to unknown when a new token is set. I hope it should be right approach. Because its new and unknown at this point. 7. `IterableConfig` has final boolean `autoRetryOnJwtFailure`. Its not something I want customers to be able to configure. It should be removed before going to master. It should be internal only variable. 8. IterableRequestTask - has some changes introduced due to the flow not falling under jwt failure. Response code coming has -1 was the root cause. Hence the change around responseCode >= 0 && responseCode < 400 9. `IterableRequestTask` - Line 215 - Still not sure if RequestProcessor check should happen. It does make sense to have it as only offline stored request will be reprocessed. And this feature should only work for those requests going through offline Request processor 10. `IterableRequestTask` - fromJSON method change is something I havent checked properly. I think its for unit testing the changes are done. 11. IterableTaskRunner. Would like to see if I can remove the method - isJWTFailure(responseCode). May be its a small abstraction thats needed. 12. Havent checked unit tests properly yet
41bc71a to
b691ea2
Compare
franco-zalamena-iterable
approved these changes
Mar 10, 2026
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
Adds automatic JWT retry for offline-queued requests. When a stored offline task receives a 401 JWT error, instead of retrying inline, the task is retained in the DB and task processing pauses until a fresh token is obtained.
Changes by file
IterableApi.java
autoRetryflag from remote configuration and persists it in SharedPreferences.isAutoRetryOnJwtFailure()for internal use only (not customer-facing).IterableAuthManager.java
AuthStateenum (VALID,INVALID,UNKNOWN) to represent JWT token health.AuthTokenReadyListenerpub/sub so components (e.g.,IterableTaskRunner) can react when a new token is available.handleAuthTokenSuccesssets state toUNKNOWN(new token, not yet verified);setIsLastAuthTokenValid(true)transitions toVALID.INVALID→ non-INVALIDnotify listeners to resume processing.IterableTaskRunner.java
AuthTokenReadyListener. On JWT 401, marks authINVALID, pauses processing, and returnsRETRYwithout deleting the task.onAuthTokenReady()callback, resumes task processing with the fresh token.authTokenOverrideinfromJSON) instead of the stale one stored in the DB at queue time.IterableRequestTask.java
autoRetryis enabled and the request is offline, skips inline retry and schedules a delayed auth token refresh instead —IterableTaskRunnerhandles the retry.getErrorStream()andresponseCode >= 0guard against network inspector interference returning -1.responseCode == -1but response body contains JWT error codes, infers 401.fromJSONoverload accepts optionalauthTokenOverridefor injecting fresh tokens into deserialized offline tasks.OfflineRequestProcessor.java
taskRunnerasAuthTokenReadyListeneron construction.dispose()method unregisters the listener to prevent stale accumulation when offline mode is toggled.IterableApiClient.java
dispose()on the oldOfflineRequestProcessorbefore replacing it insetOfflineProcessingEnabled().Resolved concerns from earlier draft
→ Removed fromIterableConfig.autoRetryOnJwtFailureshould not be customer-facingIterableConfig(commit be05ccb). Flag is now remote-config only.→ Used byfromJSONauthTokenOverride purpose unclearTaskRunner.processTask()to inject fresh token into stale DB tasks. Correct architectural choice (task-management concern belongs in TaskRunner, not RequestTask).→ Kept as a small, well-named abstraction. In offline context, any 401 is treated as JWT failure since the API key was valid at queue time.isJwtFailuremethod redundant?responseCode -1 handling→ Defensive heuristic kept. Null errorStream check is valid per Android HttpURLConnection docs.registerDeviceTokenis called repeatedly on every JWT rotation.setAuthToken()callscompleteUserLogin()whenever the token string changes.completeUserLogin()unconditionally callsregisterForPush(),syncInApp(), andsyncMessages(). This means every JWT refresh (e.g. on expiration) triggers a full re-registration cycle even though the user identity (email/userId) and push token (FCM) haven't changed.completeUserLoginwas designed for user identity changes (setEmail/setUserId), where re-registering makes sense. ButsetAuthTokenalso triggers it on routine JWT rotation, causing unnecessary API calls.setAuthTokenshould distinguish between "new user login" and "credential refresh" to avoid redundant work.Needs a separate ticket to address.