You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MP Metrics 5.1 added the ability for users configure percentile and bucket settings in microprofile-config.properties.
Helidon MP initializes these settings as part of the metrics CDI extension late-stage start-up work. As usual, in the absence of config settings for these values Helidon applies defaults.
A user reports that a test that uses MP metrics but which does not use @HelidonTest and therefore does not initialize the Helidon MP container began to fail starting with Helidon 4.1.4. That's because, without the metrics CDI extension running, no code initializes the new config settings. As a result, attempts by metrics to dereference the settings threw an NPE.
An easy workaround is to annotated such tests with @HelidonTest. It would also be simple enough for Helidon to provide initial default settings, subject to change during actual startup, to avoid such NPEs.
Steps to reproduce
Create a test without @HelidonTest, run separately from tests with that annotation:
classTestDistributionCustomizationsNoInit {
privatestaticMetricRegistrymetricRegistry;
@BeforeAllstaticvoidinitRegistry() {
metricRegistry = RegistryFactory.getInstance().getRegistry(MetricRegistry.APPLICATION_SCOPE);
}
@TestvoidcheckDistributionCustomizations() {
// The following triggers an NPE because this test does not use @HelidonTest// and therefore the normal metrics CDI extension initialization code --which sets up the distribution// customizations -- does not run.Timertimer = metricRegistry.timer("testTimer");
assertThat("Timer", timer, notNullValue());
}
}
The text was updated successfully, but these errors were encountered:
Environment Details
Problem Description
MP Metrics 5.1 added the ability for users configure percentile and bucket settings in
microprofile-config.properties
.Helidon MP initializes these settings as part of the metrics CDI extension late-stage start-up work. As usual, in the absence of config settings for these values Helidon applies defaults.
A user reports that a test that uses MP metrics but which does not use
@HelidonTest
and therefore does not initialize the Helidon MP container began to fail starting with Helidon 4.1.4. That's because, without the metrics CDI extension running, no code initializes the new config settings. As a result, attempts by metrics to dereference the settings threw an NPE.An easy workaround is to annotated such tests with
@HelidonTest
. It would also be simple enough for Helidon to provide initial default settings, subject to change during actual startup, to avoid such NPEs.Steps to reproduce
Create a test without
@HelidonTest
, run separately from tests with that annotation:The text was updated successfully, but these errors were encountered: