Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public <T> T timeSupplier(Supplier<T> event) {
*/
@Override
public void time(Runnable event) {
// NOP
event.run();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
Expand Down Expand Up @@ -494,4 +495,13 @@ void registerNullMetric() {
.isThrownBy(() -> registry.register(MetricName.build("any_name"), null))
.withMessage("metric == null");
}

@Test
void timesRunnableInstances() {
Timer timer = registry.timer("thing");
final AtomicBoolean called = new AtomicBoolean();
timer.time(() -> called.set(true));

assertThat(called).isTrue();
}
}