Skip to content

Commit a8ff508

Browse files
authored
Fix spring kafka latest dep test (#15362)
1 parent 5e1a311 commit a8ff508

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

instrumentation/spring/spring-boot-autoconfigure/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies {
3636
annotationProcessor("org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion")
3737
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
3838
implementation("javax.validation:validation-api")
39+
compileOnly("org.springframework.kafka:spring-kafka:2.9.0")
3940

4041
implementation(project(":instrumentation-annotations-support"))
4142
implementation(project(":instrumentation:kafka:kafka-clients:kafka-clients-2.6:library"))
@@ -56,7 +57,6 @@ dependencies {
5657
implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java8:library"))
5758
implementation(project(":instrumentation:runtime-telemetry:runtime-telemetry-java17:library"))
5859

59-
library("org.springframework.kafka:spring-kafka:2.9.0")
6060
library("org.springframework.boot:spring-boot-starter-actuator:$springBootVersion")
6161
library("org.springframework.boot:spring-boot-starter-aop:$springBootVersion")
6262
library("org.springframework.boot:spring-boot-starter-web:$springBootVersion")

instrumentation/spring/spring-kafka-2.7/testing/src/main/java/io/opentelemetry/testing/AbstractSpringKafkaTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.context.ConfigurableApplicationContext;
3131
import org.springframework.kafka.core.KafkaOperations;
3232
import org.springframework.kafka.core.KafkaTemplate;
33-
import org.springframework.util.concurrent.ListenableFuture;
3433
import org.testcontainers.containers.wait.strategy.Wait;
3534
import org.testcontainers.kafka.KafkaContainer;
3635
import org.testcontainers.utility.DockerImageName;
@@ -98,14 +97,16 @@ void tearDownApp() {
9897
MethodHandle sendMethod = null;
9998
Exception failure = null;
10099
try {
100+
Class<?> listenableFutureClass =
101+
Class.forName("org.springframework.util.concurrent.ListenableFuture");
101102
sendMethod =
102103
MethodHandles.lookup()
103104
.findVirtual(
104105
KafkaOperations.class,
105106
"send",
106107
MethodType.methodType(
107-
ListenableFuture.class, String.class, Object.class, Object.class));
108-
} catch (NoSuchMethodException e) {
108+
listenableFutureClass, String.class, Object.class, Object.class));
109+
} catch (ClassNotFoundException | NoSuchMethodException e) {
109110
// spring-kafka 3.0 changed the return type
110111
try {
111112
sendMethod =

0 commit comments

Comments
 (0)