Handle errors in both subscriptions.

Previously errors in CachingRouteLocator were on handled on the interior subscribe, not it is handled in both.

Fixes gh-1892
This commit is contained in:
spencergibb
2021-03-15 13:34:49 -04:00
parent 6c7ac3c590
commit 702c9aaeee
2 changed files with 2 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ public class CachingRouteLocator
list -> Flux.fromIterable(list).materialize().collect(Collectors.toList()).subscribe(signals -> {
applicationEventPublisher.publishEvent(new RefreshRoutesResultEvent(this));
cache.put(CACHE_KEY, signals);
}, throwable -> handleRefreshError(throwable)));
}, this::handleRefreshError), this::handleRefreshError);
}
catch (Throwable e) {
handleRefreshError(e);

View File

@@ -21,7 +21,6 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Ignore;
import org.junit.Test;
import reactor.core.publisher.Flux;
@@ -67,7 +66,6 @@ public class CachingRouteLocatorTests {
}
@Test
@Ignore // FIXME: 3.0.0
public void refreshWorksWhenFirstRefreshSuccessAndOtherError() throws InterruptedException {
Route route1 = route(1);
Route route2 = route(2);
@@ -102,7 +100,7 @@ public class CachingRouteLocatorTests {
waitUntilRefreshFinished(locator, resultEvents);
assertThat(resultEvents).hasSize(1);
assertThat(resultEvents.get(0).getThrowable().getCause().getMessage()).isEqualTo("in chain.");
assertThat(resultEvents.get(0).getThrowable().getMessage()).isEqualTo("in chain.");
assertThat(resultEvents.get(0).isSuccess()).isEqualTo(false);
assertThat(locator.getRoutes().collectList().block()).containsExactly(route1);