From 3188c06a16ab8d8eea6c8f9c79ba39af448512d0 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 14 Mar 2024 11:49:00 -0400 Subject: [PATCH] Remove `ObservationTests.observationErrorException` The Micrometer Observation of version `1.10` does not support catching `Error` yet --- .../support/micrometer/ObservationTests.java | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java index 1add6ab14d..c8cd57d9dc 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java @@ -90,14 +90,12 @@ */ @SpringJUnitConfig @EmbeddedKafka(topics = { "observation.testT1", "observation.testT2", "observation.testT3", - ObservationTests.OBSERVATION_RUNTIME_EXCEPTION, ObservationTests.OBSERVATION_ERROR}) + ObservationTests.OBSERVATION_RUNTIME_EXCEPTION}) @DirtiesContext public class ObservationTests { public final static String OBSERVATION_RUNTIME_EXCEPTION = "observation.runtime-exception"; - public final static String OBSERVATION_ERROR = "observation.error"; - @Test void endToEnd(@Autowired Listener listener, @Autowired KafkaTemplate template, @Autowired SimpleTracer tracer, @Autowired KafkaListenerEndpointRegistry rler, @@ -256,27 +254,6 @@ void observationRuntimeException(@Autowired ExceptionListener listener, @Autowir .hasMessage("obs4 run time exception"); } - @Test - void observationErrorException(@Autowired ExceptionListener listener, @Autowired SimpleTracer tracer, - @Autowired @Qualifier("throwableTemplate") KafkaTemplate errorTemplate, - @Autowired KafkaListenerEndpointRegistry endpointRegistry) - throws ExecutionException, InterruptedException, TimeoutException { - - errorTemplate.send(OBSERVATION_ERROR, "testError").get(10, TimeUnit.SECONDS); - assertThat(listener.latch5.await(10, TimeUnit.SECONDS)).isTrue(); - endpointRegistry.getListenerContainer("obs5").stop(); - - Deque spans = tracer.getSpans(); - assertThat(spans).hasSize(2); - SimpleSpan span = spans.poll(); - assertThat(span.getTags().get("spring.kafka.template.name")).isEqualTo("throwableTemplate"); - span = spans.poll(); - assertThat(span.getTags().get("spring.kafka.listener.id")).isEqualTo("obs5-0"); - assertThat(span.getError()) - .isInstanceOf(Error.class) - .hasMessage("obs5 error"); - } - @Configuration @EnableKafka public static class Config { @@ -457,12 +434,6 @@ void listenRuntimeException(ConsumerRecord in) { throw new IllegalStateException("obs4 run time exception"); } - @KafkaListener(id = "obs5", topics = OBSERVATION_ERROR) - void listenError(ConsumerRecord in) { - this.latch5.countDown(); - throw new Error("obs5 error"); - } - } }