Various polishing to accomodate boot, reactor and other changes

This commit is contained in:
Oleg Zhurakousky
2020-08-04 19:19:36 +02:00
parent 1670563de9
commit ddba54dee6
5 changed files with 53 additions and 47 deletions

View File

@@ -16,8 +16,8 @@
package org.springframework.cloud.function.web.source;
import java.net.ConnectException;
import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.Set;
import java.util.function.Supplier;
@@ -28,6 +28,7 @@ import org.reactivestreams.Publisher;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;
import org.springframework.cloud.function.context.FunctionCatalog;
import org.springframework.context.SmartLifecycle;
@@ -106,22 +107,24 @@ public class SupplierExporter implements SmartLifecycle {
}
if (suppliersPresent) {
this.subscription = streams
.retry(error -> {
/*
* The ConnectException may happen if a server is not yet available/reachable
* The ClassCast is to handle delayed Mono issued by HttpSupplier.transform for non-2xx responses
*/
boolean retry = error instanceof ConnectException || error instanceof ClassCastException
&& this.running;
if (!retry) {
this.ok = false;
if (!this.debug) {
logger.info(error);
}
stop();
}
return retry;
})
.retryWhen(Retry.backoff(5, Duration.ofSeconds(1)))
// .retry(error -> {
// /*
// * The ConnectException may happen if a server is not yet available/reachable
// * The ClassCast is to handle delayed Mono issued by HttpSupplier.transform for non-2xx responses
// */
// boolean retry = error instanceof ConnectException || error instanceof ClassCastException
// && this.running;
// if (!retry) {
// this.ok = false;
// if (!this.debug) {
// logger.info(error);
// }
// stop();
// }
// return retry;
// }
// )
.doOnComplete(() -> {
stop();
})