Prevent repository metrics from causing a circular reference

Fixes gh-27591
This commit is contained in:
Andy Wilkinson
2021-08-12 10:05:31 +01:00
parent f2c3c0d207
commit 35ea3b234d
5 changed files with 56 additions and 15 deletions

View File

@@ -53,13 +53,13 @@ class MetricsRepositoryMethodInvocationListenerTests {
void setup() {
MockClock clock = new MockClock();
this.registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock);
this.listener = new MetricsRepositoryMethodInvocationListener(this.registry,
this.listener = new MetricsRepositoryMethodInvocationListener(() -> this.registry,
new DefaultRepositoryTagsProvider(), REQUEST_METRICS_NAME, AutoTimer.ENABLED);
}
@Test
void afterInvocationWhenNoTimerAnnotationsAndNoAutoTimerDoesNothing() {
this.listener = new MetricsRepositoryMethodInvocationListener(this.registry,
this.listener = new MetricsRepositoryMethodInvocationListener(() -> this.registry,
new DefaultRepositoryTagsProvider(), REQUEST_METRICS_NAME, null);
this.listener.afterInvocation(createInvocation(NoAnnotationsRepository.class));
assertThat(this.registry.find(REQUEST_METRICS_NAME).timers()).isEmpty();