Skip to content

Commit ab76a5c

Browse files
authored
Review fixes for spring-webflux-5.3:library (open-telemetry#17747)
1 parent 8f1b47f commit ab76a5c

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

instrumentation/spring/spring-webflux/spring-webflux-5.3/library/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (!otelProps.testLatestDeps) {
3434
}
3535

3636
tasks {
37-
test {
37+
withType<Test>().configureEach {
3838
systemProperty("collectMetadata", otelProps.collectMetadata)
3939
}
4040

instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/test/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxServerInstrumentationTest.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static org.assertj.core.api.Assertions.assertThat;
1010
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1111

12+
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
1213
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
1314
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerTest;
1415
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
@@ -26,21 +27,23 @@
2627
import org.junit.jupiter.api.extension.RegisterExtension;
2728
import org.springframework.context.ConfigurableApplicationContext;
2829

29-
public class SpringWebfluxServerInstrumentationTest
30+
class SpringWebfluxServerInstrumentationTest
3031
extends AbstractHttpServerTest<ConfigurableApplicationContext> {
3132

3233
private static final String CONTEXT_PATH = "/test";
3334

3435
@RegisterExtension
3536
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forLibrary();
3637

38+
@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();
39+
3740
@Override
3841
protected ConfigurableApplicationContext setupServer() {
3942
return TestWebfluxSpringBootApp.start(port, CONTEXT_PATH);
4043
}
4144

4245
@Override
43-
public void stopServer(ConfigurableApplicationContext applicationContext) {
46+
protected void stopServer(ConfigurableApplicationContext applicationContext) {
4447
applicationContext.close();
4548
}
4649

@@ -79,16 +82,16 @@ void cancelRequest() throws InterruptedException {
7982
String method = "GET";
8083
AggregatedHttpRequest request = request(endpoint, method);
8184

82-
try (ClientRequestContextCaptor captor = Clients.newContextCaptor()) {
83-
CompletableFuture<AggregatedHttpResponse> future =
84-
client.execute(request).aggregate().toCompletableFuture();
85-
ClientRequestContext clientRequestContext = captor.get();
86-
Thread.sleep(1_000);
87-
clientRequestContext.cancel();
88-
assertThatThrownBy(future::join)
89-
.isInstanceOf(CompletionException.class)
90-
.hasMessage(ResponseCancellationException.class.getName());
91-
}
85+
ClientRequestContextCaptor captor = Clients.newContextCaptor();
86+
cleanup.deferCleanup(captor);
87+
CompletableFuture<AggregatedHttpResponse> future =
88+
client.execute(request).aggregate().toCompletableFuture();
89+
ClientRequestContext clientRequestContext = captor.get();
90+
Thread.sleep(1_000);
91+
clientRequestContext.cancel();
92+
assertThatThrownBy(future::join)
93+
.isInstanceOf(CompletionException.class)
94+
.hasMessage(ResponseCancellationException.class.getName());
9295

9396
assertTheTraces(1, null, null, null, method, endpoint);
9497
}

instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/test/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/TestWebfluxSpringBootApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Mono<String> indexed_child(@RequestParam("id") String id) {
138138
}
139139

140140
@GetMapping("/cancel")
141-
public Mono<String> cancel() {
141+
Mono<String> cancel() {
142142
return controller(SUCCESS, () -> Mono.never());
143143
}
144144
}

0 commit comments

Comments
 (0)