Skip to content

Bump to 2.7.8, minor bug fixes#382

Merged
ianrumac merged 2 commits intomainfrom
develop
Mar 12, 2026
Merged

Bump to 2.7.8, minor bug fixes#382
ianrumac merged 2 commits intomainfrom
develop

Conversation

@ianrumac
Copy link
Collaborator

@ianrumac ianrumac commented Mar 12, 2026

Changes in this pull request

2.7.8

Fixes

  • Fix serialization issue with R8 and dates
  • Fix scope cancellation for test mode

Checklist

  • All unit tests pass.
  • All UI tests pass.
  • Demo project builds and runs.
  • I added/updated tests or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run ktlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

Greptile Summary

This is a small patch release (2.7.7 → 2.7.8) that ships two targeted bug fixes: adding SupervisorJob() to IOScope/MainScope so that a failing child coroutine no longer cancels the whole scope (fixing test-mode cancellation), and adding Date support to the Room Converters — both in the sanitizeMap allow-list and as an R8-safe Java-reflection fallback in convertToJsonElement.

Key changes:

  • Scopes.ktSupervisorJob() prepended to both scope contexts; clean and correct fix.
  • Converters.ktDate added to sanitizeMap filter; R8 fallback else branch added in convertToJsonElement. The fallback has a misleading comment ("string representation") that does not match the actual behaviour (JsonNull is returned for non-Date unknowns, not a string). Additionally, the this != null guard inside the else branch is redundant because null is already matched earlier in the when expression.
  • CHANGELOG.md / version.env — version bumped to 2.7.8.

Confidence Score: 4/5

  • This PR is safe to merge with minor polish needed in Converters.kt.
  • Both fixes are narrowly scoped and correct. The SupervisorJob addition in Scopes.kt is a well-understood coroutines pattern. The Date serialization fix in Converters.kt works correctly for its primary purpose; the only concerns are a misleading comment and a redundant null check — neither affects runtime behaviour.
  • superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt — review the misleading comment and redundant null guard in the else branch of convertToJsonElement.

Important Files Changed

Filename Overview
superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt Adds SupervisorJob() to IOScope and MainScope so that failure of a child coroutine no longer cancels the entire scope. This is a correct and well-scoped fix for the reported test-mode cancellation bug.
superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt Adds Date handling to sanitizeMap and a Java-reflection-based fallback for R8-related Date serialization. The fallback has a misleading comment (says "string representation" but returns JsonNull) and a redundant null guard.
CHANGELOG.md Adds 2.7.8 changelog entry describing the two bug fixes included in this release.
version.env Bumps SUPERWALL_VERSION from 2.7.7 to 2.7.8.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Any?.convertToJsonElement] --> B{when this}
    B -->|null| C[JsonNull]
    B -->|String / Number / Boolean| D[JsonPrimitive]
    B -->|Date - Kotlin is check| E[JsonPrimitive - date.time]
    B -->|JSONArray / JSONObject| F[JsonArray / JsonObject]
    B -->|List / Array / Map| G[JsonArray / JsonObject]
    B -->|else - R8 fallback| H{Date::class.java.isInstance?}
    H -->|yes| I[JsonPrimitive - date.time]
    H -->|no| J[JsonNull - silent data loss]

    subgraph Scopes
        K[IOScope / MainScope] --> L[SupervisorJob + Dispatcher + ExceptionHandler]
        L --> M[Child failure does NOT cancel parent scope]
    end
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt
Line: 100-109

Comment:
**Comment contradicts implementation**

The inline comment says "convert any other unknown types to their **string representation** instead of crashing", but the code actually returns `JsonNull`, not a string. This means unknown types will silently become `null` in JSON rather than being preserved as a string. If the intent truly was to preserve the value as a string, it should call `JsonPrimitive(this.toString())`. If `JsonNull` is intentional, the comment should be updated to reflect that.

```suggestion
        else -> {
            // Fallback: handle Date by Java class check in case R8 optimizes away the
            // instanceof check above. Any other unknown types are converted to null.
            if (Date::class.java.isInstance(this)) {
                JsonPrimitive((this as Date).time)
            } else {
                JsonNull
            }
        }
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt
Line: 104

Comment:
**Redundant null check in `else` branch**

Because the `when` expression already handles the `null -> JsonNull` case on line 79, by the time execution reaches this `else` branch `this` is guaranteed to be non-null. The `if (this != null && ...)` guard is therefore redundant and can be simplified.

```suggestion
            if (Date::class.java.isInstance(this)) {
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: 6b351c1

Greptile also left 2 inline comments on this PR.

…nverters.kt

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@ianrumac ianrumac merged commit ea77d1e into main Mar 12, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant