Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import datadog.trace.bootstrap.instrumentation.api.Tags
import datadog.trace.bootstrap.instrumentation.api.URIUtils
import datadog.trace.instrumentation.netty41.client.NettyHttpClientDecorator
import datadog.trace.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator
import io.netty.channel.Channel
import org.springframework.http.HttpMethod
import org.springframework.web.reactive.function.client.ClientRequest
import org.springframework.web.reactive.function.client.ClientResponse
Expand Down Expand Up @@ -44,7 +45,28 @@ abstract class SpringWebfluxHttpClientBase extends HttpClientTest implements Tes

check()

response.statusCode().value()
consumeResponse(response)
}

protected static int consumeResponse(ClientResponse response) {
int status = response.statusCode().value()
Channel channel = responseChannel(response)
response.bodyToMono(Void).block()
Comment thread
amarziali marked this conversation as resolved.
Comment thread
amarziali marked this conversation as resolved.
// Body completion can occur inside channelRead, before channelReadComplete is fired.
channel.eventLoop().submit({} as Runnable).sync()
return status
}

private static Channel responseChannel(ClientResponse response) {
def clientHttpResponse = field(response, "response")
def nettyResponse = field(clientHttpResponse, "response")
return nettyResponse.channel()
}

private static Object field(Object target, String name) {
def field = target.class.getDeclaredField(name)
field.accessible = true
Comment thread
amarziali marked this conversation as resolved.
return field.get(target)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SpringWebfluxHttpClientDoAfterTerminateTest extends SpringWebfluxHttpClien

check()

response.statusCode().value()
consumeResponse(response)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class SpringWebfluxHttpClientDoOnSuccessOrErrorTest extends SpringWebfl

check()

response.statusCode().value()
consumeResponse(response)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SpringWebfluxHttpClientDoOnSuccessTest extends SpringWebfluxHttpClientBase

check()

response.statusCode().value()
consumeResponse(response)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SpringWebfluxHttpClientDoOnTerminateTest extends SpringWebfluxHttpClientBa

check()

response.statusCode().value()
consumeResponse(response)
}

@Override
Expand Down
Loading