Summary
In src/main/java/dev/openfga/sdk/telemetry/Metrics.java:30-32, the Metrics constructor silently mutates the caller's Configuration:
if (this.configuration.getTelemetryConfiguration() == null) {
this.configuration.telemetryConfiguration(new TelemetryConfiguration());
}
Impact
- Side effect in constructor — Constructors should not modify their inputs.
- Shared Configuration objects are unsafe — If a
Configuration is shared across contexts, one path creating Metrics will silently add a TelemetryConfiguration that affects all other users of that object.
Proposed Fix
Instead of mutating the configuration, handle the null case defensively in the methods that read telemetry config. Alternatively, ensure a non-null default TelemetryConfiguration is set during Configuration construction so the null check is never needed.
Related
Summary
In
src/main/java/dev/openfga/sdk/telemetry/Metrics.java:30-32, theMetricsconstructor silently mutates the caller'sConfiguration:Impact
Configurationis shared across contexts, one path creatingMetricswill silently add aTelemetryConfigurationthat affects all other users of that object.Proposed Fix
Instead of mutating the configuration, handle the null case defensively in the methods that read telemetry config. Alternatively, ensure a non-null default
TelemetryConfigurationis set duringConfigurationconstruction so the null check is never needed.Related