Skip to content

fix: Don't use computeIfAbsent in PerContextEventSummarizer - #226

Merged
abelonogov-ld merged 1 commit into
mainfrom
andrey/per-context-summarizer-android-api-level
Sep 28, 2026
Merged

abelonogov-ld merged 1 commit into
mainfrom
andrey/per-context-summarizer-android-api-level

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality (behavior is unchanged; covered by the existing tests)
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

The Android client SDK supports API 21 and up, and summarizes per context with PerContextEventSummarizer.

Describe the solution you've provided

Android below API 24 has neither Map.computeIfAbsent nor java.util.function. D8 turns the EventSummarizer::new reference into a synthetic Function, so the first flag evaluation in a client-side SDK on API 21–23 throws NoClassDefFoundError.

summarizeEvent now does a get and, on a miss, a put, which behaves the same. The existing PerContextEventSummarizerTest (18 tests) and EventSummarizerTest (7 tests) pass unchanged.

Describe alternatives you've considered

Having the Android SDK fall back to the aggregated EventSummarizer below API 24. That works around it for one consumer, but leaves the shared class unusable on those API levels.

Additional context

No public API change.


Note

Overview
Fixes client-side event summarization on Android API 21–23, where the first flag evaluation could crash with NoClassDefFoundError because Map.computeIfAbsent and java.util.function are unavailable and D8 turns EventSummarizer::new into a synthetic Function.

PerContextEventSummarizer.summarizeEvent now uses get / create / put instead of computeIfAbsent, with the same per-context summarizer behavior. No public API change; existing tests cover the behavior.

Reviewed by Cursor Bugbot for commit c12de8f. Bugbot is set up for automated code reviews on this repo. Configure here.

Android below API 24 has neither Map.computeIfAbsent nor java.util.function. D8
turns the EventSummarizer::new reference into a synthetic Function, so the first
evaluation in a client-side SDK on API 21-23 throws NoClassDefFoundError.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner September 28, 2026 15:23
@abelonogov-ld
abelonogov-ld merged commit 6b02b08 into main Sep 28, 2026
27 checks passed
@abelonogov-ld
abelonogov-ld deleted the andrey/per-context-summarizer-android-api-level branch September 28, 2026 16:21
abelonogov-ld pushed a commit that referenced this pull request Sep 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.12.1](launchdarkly-java-sdk-internal-1.12.0...launchdarkly-java-sdk-internal-1.12.1)
(2026-09-28)


### Bug Fixes

* Don't use computeIfAbsent in PerContextEventSummarizer
([#226](#226))
([6b02b08](6b02b08))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release `launchdarkly-java-sdk-internal` 1.12.1** via Release
Please: bumps `lib/shared/internal` from **1.12.0** to **1.12.1** in
`.release-please-manifest.json`, `gradle.properties`, and adds the
**1.12.1** changelog entry.
> 
> The release captures bug fix **#226**: **`PerContextEventSummarizer`**
no longer uses `Map.computeIfAbsent` when creating per-context
summarizers—it uses explicit **get / put** so the code runs on **Android
below API 24**, where `computeIfAbsent` and `java.util.function` are
unavailable.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
def7831. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants