Skip to content

Commit

Permalink
Merge branch '1.5.x' into 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Apr 14, 2021
2 parents 750a5be + 0c63ce4 commit 3b48e83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ private <M extends Meter> void removePollableMeter(M m) {

void poll() {
for (StatsdPollable pollableMeter : pollableMeters.values()) {
pollableMeter.poll();
try {
pollableMeter.poll();
} catch (RuntimeException e) {
// Silently ignore misbehaving pollable meter
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@

import static java.util.Collections.singletonList;
import static java.util.stream.IntStream.range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.assertj.core.api.Assertions.*;

/**
* Tests for {@link StatsdMeterRegistry}.
Expand Down Expand Up @@ -544,6 +543,17 @@ void stopTrackingMetersThatAreRemoved() {
assertThat(lines.get("functioncounter")).isEqualTo(1);
}

@Test
void pollFailureNotFatal() {
registry = StatsdMeterRegistry.builder(StatsdConfig.DEFAULT).build();
Gauge.builder("fails", "", o -> {
throw new RuntimeException();
}).register(registry);
Gauge.builder("works", () -> 42).register(registry);

assertThatCode(() -> registry.poll()).doesNotThrowAnyException();
}

@Test
@Issue("#2064")
void publishLongTaskTimerMax() throws InterruptedException {
Expand Down

0 comments on commit 3b48e83

Please sign in to comment.