fix: fix spring gateway plugin npe (#7389)

This commit is contained in:
wallezhang 2021-07-29 21:08:27 +08:00 committed by GitHub
parent 1f28d2036a
commit b74778f0f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -41,6 +41,7 @@ Release Notes.
* Remove the logic of generating instance name in `KafkaServiceManagementServiceClient` class.
* Improve `okhttp` plugin performance by optimizing Class.getDeclaredField().
* Fix `GRPCLogClientAppender` no context warning.
* Fix `spring-webflux-5.x-webclient-plugin` NPE.
#### OAP-Backend

View File

@ -34,7 +34,6 @@ import reactor.core.publisher.Mono;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.function.BiConsumer;
public class WebFluxWebClientInterceptor implements InstanceMethodsAroundInterceptorV2 {
@ -79,15 +78,12 @@ public class WebFluxWebClientInterceptor implements InstanceMethodsAroundInterce
}
Mono<ClientResponse> ret1 = (Mono<ClientResponse>) ret;
AbstractSpan span = (AbstractSpan) context.getContext();
return ret1.doAfterSuccessOrError(new BiConsumer<ClientResponse, Throwable>() {
@Override
public void accept(ClientResponse clientResponse, Throwable throwable) {
HttpStatus httpStatus = clientResponse.statusCode();
if (httpStatus != null) {
Tags.STATUS_CODE.set(span, Integer.toString(httpStatus.value()));
if (httpStatus.isError()) {
span.errorOccurred();
}
return ret1.doOnSuccess(clientResponse -> {
HttpStatus httpStatus = clientResponse.statusCode();
if (httpStatus != null) {
Tags.STATUS_CODE.set(span, Integer.toString(httpStatus.value()));
if (httpStatus.isError()) {
span.errorOccurred();
}
}
}).doOnError(error -> {