Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible NPE if user code creates a REST client 'early' #9554

Merged

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Dec 4, 2024

Description

If user code creates a REST client before CDI announced that app-scoped beans have been initialized, then the Helidon REST client metrics CDI extension attempts to use its MetricRegistry field before it has been set. (That happens in a @Observes @Initialized(ApplicationScoped.class) event observer method.)

This PR adds the ability to record such "early" REST clients (rather than acting on them immediately) if the metric registry field is null, and then once CDI provides the metric registry that observer method registers metrics for the so-called deferred REST clients.

This PR also cleans up some unrelated IDE-flagged items.

Documentation

No impact.

@tjquinno tjquinno added this to the 4.1.5 milestone Dec 4, 2024
@tjquinno tjquinno requested a review from spericas December 4, 2024 14:07
@tjquinno tjquinno self-assigned this Dec 4, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 4, 2024
@tjquinno tjquinno merged commit 189ca35 into helidon-io:main Dec 4, 2024
46 checks passed
@tjquinno tjquinno deleted the 4.x-rest-client-metrics-init-deferral branch December 4, 2024 14:43
@barchetta barchetta mentioned this pull request Dec 4, 2024
17 tasks
@barchetta barchetta removed this from the 4.1.5 milestone Dec 4, 2024
arjav-desai pushed a commit to arjav-desai/helidon that referenced this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants