Drain body after exception from applying onStatus
Closes gh-23230
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -455,9 +455,15 @@ class DefaultWebClient implements WebClient {
|
||||
for (StatusHandler handler : this.statusHandlers) {
|
||||
if (handler.test(response.statusCode())) {
|
||||
HttpRequest request = this.requestSupplier.get();
|
||||
Mono<? extends Throwable> exMono = handler.apply(response, request);
|
||||
exMono = exMono.flatMap(ex -> drainBody(response, ex));
|
||||
exMono = exMono.onErrorResume(ex -> drainBody(response, ex));
|
||||
Mono<? extends Throwable> exMono;
|
||||
try {
|
||||
exMono = handler.apply(response, request);
|
||||
exMono = exMono.flatMap(ex -> drainBody(response, ex));
|
||||
exMono = exMono.onErrorResume(ex -> drainBody(response, ex));
|
||||
}
|
||||
catch (Throwable ex2) {
|
||||
exMono = drainBody(response, ex2);
|
||||
}
|
||||
return errorFunction.apply(exMono);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user