From 234e7414e22b4bc81585b65f724b378fd39459b1 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 8 May 2025 17:39:04 -0700 Subject: [PATCH] Fix Jersey test by waiting for metrics For some reason metrics are not always being recorded before the check runs when a full build is running. Adding a sleep seems to "solve" the problem. See gh-45483 See gh-45404 --- .../jersey/JerseyServerMetricsAutoConfigurationTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java index e117e02359d..aea79842ce4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/jersey/JerseyServerMetricsAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +82,7 @@ class JerseyServerMetricsAutoConfigurationTests { void httpRequestsAreTimed() { this.webContextRunner.run((context) -> { doRequest(context); + Thread.sleep(500); MeterRegistry registry = context.getBean(MeterRegistry.class); Timer timer = registry.get("http.server.requests").tag("uri", "/users/{id}").timer(); assertThat(timer.count()).isOne();