Skip to content

Commit

Permalink
fix: recursive method call may lead to stack overflow exception
Browse files Browse the repository at this point in the history
fixes AM-3317
  • Loading branch information
lgw-gravitee authored and jhaeyaert committed Jun 17, 2024
1 parent 41529fa commit 2640c77
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import io.gravitee.node.api.secrets.resolver.PropertyResolver;
import io.gravitee.node.api.secrets.resolver.PropertyResolverFactoriesLoader;
import io.gravitee.node.api.secrets.resolver.WatchablePropertyResolver;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -80,9 +82,10 @@ public Object getProperty(String name) {
protected abstract Object getValue(String key);

private void watchProperty(WatchablePropertyResolver<?> propertyResolver, String name, Object value) {
propertyResolver
.watch(value.toString())
.doOnComplete(() -> watchProperty(propertyResolver, name, value))
Flowable
.defer(() -> propertyResolver.watch(value.toString()))
.subscribeOn(Schedulers.io())
.repeat()
.subscribe(newValue -> source.put(name, newValue), t -> LOGGER.error("Unable to update property {}", name, t));
}

Expand Down

0 comments on commit 2640c77

Please sign in to comment.