Skip to content

Commit

Permalink
Eliminate unnecessary null check
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Dec 2, 2024
1 parent f296b41 commit 1a2c539
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,22 +616,18 @@ private Meter getOrCreateMeter(@Nullable DistributionStatisticConfig config,
BiFunction<Id, /* Nullable Generic */ DistributionStatisticConfig, ? extends Meter> builder, Id originalId,
Id mappedId, Function<Meter.Id, ? extends Meter> noopBuilder) {
Meter m = meterMap.get(mappedId);
checkAndWarnAboutGaugeDoubleRegistration(m);

if (m != null) {
checkAndWarnAboutGaugeDoubleRegistration(m);
}
else {
if (m == null) {
if (isClosed()) {
return noopBuilder.apply(mappedId);
}

synchronized (meterMapLock) {
m = meterMap.get(mappedId);
checkAndWarnAboutGaugeDoubleRegistration(m);

if (m != null) {
checkAndWarnAboutGaugeDoubleRegistration(m);
}
else {
if (m == null) {
if (!accept(mappedId)) {
return noopBuilder.apply(mappedId);
}
Expand Down

0 comments on commit 1a2c539

Please sign in to comment.