4.1.5: Initialize distribution customizations even before config is applied #9564
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.
Backport #9547 to Helidon 4.1.5
Description
Resolves #9546
We added a new data structure,
DistributionCustomizations
, in Helidon 4.1.4 to support an enhancement in MP metrics 5.1 to allow configuration of percentiles, buckets, etc.Under normal conditions, the Helidon MP metrics CDI extension invokes this type's
init
method with an MP config object to prepare the various customizations and all is well.A user wrote a test that used MP metrics (a timer specifically) but did not mark the test with
@HelidonTest
so the initialization described above did not occur. That caused an NPE.We have also since had a report of this happening in an app, in which a CDI extension attempts to register a timer before the metrics CDI extension has prepared metrics properly. As with the test use case above, this means metrics tries to use the
instance
field before it has been set.This PR modifies the
DistributionCustomizations
class to initialize the static (non-final)instance
variable at load-time without using config. This resolves the problem the user encountered with the test.Subsequently the metrics CDI extension overwrites that initial value with one derived from configuration.
Documentation
No impact.