Skip to content

fix: safely initialize exemplar reservoir storage#8524

Merged
jack-berg merged 2 commits into
open-telemetry:mainfrom
seongjun-rpls:fix/exemplar-reservoir-safe-init
Jun 24, 2026
Merged

fix: safely initialize exemplar reservoir storage#8524
jack-berg merged 2 commits into
open-telemetry:mainfrom
seongjun-rpls:fix/exemplar-reservoir-safe-init

Conversation

@seongjun-rpls

@seongjun-rpls seongjun-rpls commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes unsafe lazy initialization of FixedSizeExemplarReservoir storage.

storage is initialized on the first offered measurement, but concurrent first measurements could observe a partially initialized or stale storage reference and fail with an NPE when recording into a bucket.

This change safely publishes the initialized storage array and synchronizes the first initialization.

Fixes #8523

Testing

  • ./gradlew :sdk:metrics:check

Since this is my first PR to this repository, I apologize in advance if I've missed anything or haven't fully followed the project's conventions. Please let me know and I'll be happy to make any changes needed.

@seongjun-rpls seongjun-rpls requested a review from a team as a code owner June 23, 2026 08:07
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 23, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: seongjun-rpls / name: seongjun.ha (9642778)

@seongjun-rpls seongjun-rpls force-pushed the fix/exemplar-reservoir-safe-init branch 3 times, most recently from 4904d78 to 1d7232e Compare June 23, 2026 08:14
@seongjun-rpls seongjun-rpls force-pushed the fix/exemplar-reservoir-safe-init branch from 1d7232e to 990f3dd Compare June 23, 2026 08:16
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.52%. Comparing base (271c8dc) to head (0f19b96).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
.../internal/exemplar/FixedSizeExemplarReservoir.java 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8524   +/-   ##
=========================================
  Coverage     78.51%   78.52%           
- Complexity     8601     8603    +2     
=========================================
  Files          1013     1013           
  Lines         29148    29159   +11     
  Branches       3631     3635    +4     
=========================================
+ Hits          22885    22896   +11     
  Misses         5420     5420           
  Partials        843      843           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch and fix.

@seongjun-rpls seongjun-rpls requested a review from jack-berg June 24, 2026 09:22
@jack-berg jack-berg merged commit 1704e22 into open-telemetry:main Jun 24, 2026
28 checks passed
@otelbot

otelbot Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @seongjun-rpls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

NullPointerException in FixedSizeExemplarReservoir due to unsafe lazy initialization

2 participants